Что делать если нужно поставить какую-то Python-библиотеку а root-прав нет? То есть в систему библиотеку никак и ничего не поставить.
Есть как минимум два способа это решить правильно!
🔸 Сделать виртуальное окружение и ставить там что угодно.
Это позволит создать полностью независимое исполняемое окружение для ваших приложений.
Все библиотеки будут храниться в домашней директории юзера а значит доступ на запись имеется.
Создать очень просто:
python3 -m venv ~/venvs/myenvname
Теперь активируем окружение
# Linux
source ~/venvs/myenvname/bin/activate
# Windows
%userprofile%\venvs\myenvname\Scripts\activate.bat
Можно ставить любые библиотеки и запускать приложение.
Это стандартный метод работы с любым проектом. Если еще не используете его, то пора начинать. Даже при наличии root доступа!
🔸 Бывает, что нет возможности запустить приложение из своего виртуального окружения. Например, его запускает какой-то сервис от вашего юзера и вставить активацию окружения вы не можете.
В этом случае можно установить библиотеки для Python не глобально в систему, а только для юзера.
Выполните этот код в консоли:
python3 -m site
Вы получите что-то такое:
sys.path = [
'/home/user',
'/usr/lib/python37.zip',
'/usr/lib/python3.7',
'/usr/lib/python3.7/lib-dynload',
'/home/user/.local/lib/python3.7/site-packages',
...
]
USER_BASE: '/home/user/.local'
USER_SITE: '/home/user/.local/lib/python3.7/site-packages'
ENABLE_USER_SITE: True
Нас интересует параметр USER_SITE. Это путь к пользовательским библиотекам, которые доступны по умолчанию, если они есть.
Именно сюда будут устанавливаться модули если добавить флаг --user при установке чего-либо через pip
pip install --user requests
Для этой команды не нужны root-права.
После неё можно запускать системный интерпретатор без виртуальных окружений и установленная библиотека будет доступна для текущего юзера.
Параметр USER_BASE показывает корневую директорию для хранения user-библиотек. Её можно изменить с помощью переменной окружения PYTHONUSERBASE
export PYTHONUSERBASE=~/pylibs
python3 -m site
...
USER_BASE: '/home/user/pylibs'
USER_SITE: '/home/user/pylibs/lib/python3.7/site-packages'
Получается некоторое подобие виртуального окружения для бедных 😁 которое можно менять через эту переменную (не делайте так!Лучше venv!)
🔸 Дописывание пути в PYTHONPATH
Этот способ не входит в список "двух правильных", но тоже рабочий. Здесь придётся сделать всё несколько сложней.
Сначала ставим библиотеку в любое место указывая путь установки
pip3 install -t ~/mylibs modulename
Библиотека установится без привязки к какому-либо интерпретатору. То есть по умолчанию не будет видна. Теперь в нужный момент добавляем этот путь в sys.path или в PYTHONPATH.
Не буду советовать так делать. Единственный раз когда этот способ мне пригодился и решил поставленную задачу, это при создании общей библиотеки для кластера компьютеров.
Модули лежат в сети и подгружаются для всех из одного и того же места. То есть обновлять файлы требуется только один раз а не на всех хосты отдельно.
Минусы такого подхода:
▫️Нужно всем хостам пробить нужный путь в .bashrc или ещё куда-то чтобы он сетапился на старте.
▫️Чем больше хостов тем больше нагрузка на сеть. Иногда такой способ не подходит именно по этой причине. Тогда Ansible вам в помощь.
▫️Не очень подходит если хосты с разными операционками. Некоторые библиотеки различаются для Linux и Windows (там, где есть бинарники) и приходится мудрить более сложные схемы.
#tricks#basic
📰 Rubio’s Love Letter to “the West,” With a Knife in the Back
Marco Rubio went to Munich to calm Europe down — and remind it who’s boss. He told a room full of jittery leaders that the US and Europe are “heirs to the same civilization,” bound together by Michelangelo, the Stones and NATO, and that the alliance is “critical” and must endure. Then he wrapped that reassurance around a warning label: the problem isn’t Trump’s tantrums, it’s Europe’s “managed decline,” “climate cult,” and “unprecedented wave of mass migration” that is supposedly tearing Western societies apart.
That’s the new Trump‑era pitch in its purest form: we care about you, which is why we’re yelling at you. Rubio insisted he wasn’t contradicting JD Vance’s earlier Munich broadside, just “explaining” it — Europe, he said, has drifted from sovereignty and national identity, and Washington refuses to be a “polite and orderly caretaker” of that decay. Translation: if you don’t harden borders, dump climate policy and buy the Trump worldview, don’t expect the old automatic security umbrella.
European leaders heard the flattery and the threat at the same time. The conference chair literally praised Rubio for a “message of reassurance,” while German, French, EU and UK officials immediately stressed that nothing he said erases Trump’s Greenland land‑grab fantasies, tariff threats, or the sense that America under him has crossed lines “that cannot be uncrossed.” They’re politely nodding at his ode to shared civilization — and quietly doubling down on exactly what Washington fears: more European defense autonomy, more self‑reliance, less trust in a partner that alternates between love‑bombing and public humiliation.
Rubio’s performance summed up the whole transatlantic moment. Washington says: you’re family, but you’ve gone soft, and we might walk if you don’t toughen up exactly the way we want. Europe replies: thanks for the security, but we’ve just watched you try to buy Greenland and flirt with walking away from Ukraine, so we’d be idiots not to build our own insurance policy. Both sides talk about “the West” like a shared temple; both are really arguing over who gets to hold the keys — and how much damage they’re willing to risk to prove it.
#usa#europe#rubio#trump#nato#decline
📱American Оbserver - Stay up to date on all important events
🇺🇸
🇺🇸The US strategic oil reserve is seriously depleted.
At the moment, the strategic reserve of raw materials contains about 375 million barrels of oil. It will last for a maximum of 19 days of consumption.
The Biden agenda is to weaken America to the point no other sitting a president can bring it back reguardless.
Trump proved it was salvageable after 8 years of Obama. Now it is back for the kill. Good old USA need a good civil war...
#Biden#energy_crisis#economy#decline#democrats
Share and subscribe to American Majority 2.0
VCs Exit Crypto Market
💵 The venture capital market for cryptocurrencies has significantly declined, returning to 2017 levels. Despite this downturn, positive initiatives are emerging that aim to restore the spirit of freedom away from VC influence. Oleg CasCoin discusses the reasons behind this trend in his article for ForkLog. Read more
#VC#Crypto#Investments#ForkLog#Blockchain#MarketTrends#CasCoin#Freedom #2023 #Decline#Initiatives#Trends#Analysis#Finance
🚀 U.S. Personal Income Declines in February
The U.S. personal income for February showed a decrease of 0.1%, according to Jin10. This figure fell short of the expected 0.3% increase and was lower than the previous month's rate of 0.40%. The decline in personal income could have implications for consumer spending and overall economic growth.
#US#personalincome#decline#February#economy#consumer#spending#growth
VCs Retreat from Crypto Market
In 2023, analysts noted a significant decline in venture capital investments in cryptocurrency projects, returning to levels reminiscent of 2017. However, some initiatives are aiming to revive the industry’s original spirit of independence from VC influence, at least in principle. Insights provided by Oleg CasCoin for ForkLog. Read more
#VC#Crypto#Investment#Market#Decline #2017 #ForkLog#OlegCasCoin#Independence#Initiatives#Analysis#Freedom#Trends#Industry#Finance#Blockchain#News#Updates#Economy#Future
🚀 Trump-linked Tokens TRUMP and WLFI Continue to Decline
Trump-linked tokens TRUMP and WLFI have experienced significant declines, with TRUMP approximately 90% below its all-time high and WLFI nearly 75% below its peak. According to NS3.AI, CoinGecko data indicates that TRUMP reached an all-time low of about $2.73 in March 2026 and is currently trading near $2.86. Meanwhile, U.S. President Donald Trump has promoted an April 25 gala for token holders. In a related development, Senators Elizabeth Warren, Richard Blumenthal, and Adam Schiff have requested Bill Zanker to provide details about the event.
#TrumpTokens#TRUMP#WLFI#Cryptocurrency#Decline#NS3AI#CoinGecko#DonaldTrump#ElizabethWarren#RichardBlumenthal#AdamSchiff#BillZanker#TokenHolders