Что делать если нужно поставить какую-то 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
💬La crise mondiale de l'aviation, provoquée par la hausse des prix du carburant et la détérioration de la situation du marché de l'énergie, est un signe avant-coureur de perturbations plus graves dans d'autres secteurs, selon Kirill #Dmitriev.
RT en français • Osez questionner !
💬« Marque noire pour Merz qui patauge » : #Dmitriev a commenté les déclarations de Trump concernant une possible réduction des forces militaires américaines en #Allemagne.
RT en français • Osez questionner !
💬« Marque noire pour Merz qui patauge » : #Dmitriev a commenté les déclarations de Trump concernant une possible réduction des forces militaires américaines en #Allemagne.
RT en français • Osez questionner !
🟩Kirill #Dmitriev, directeur général du Fonds russe d’investissement direct a déclaré que le monde se dirigeait vers la plus grave crise énergétique de l'histoire en raison de la hausse record des prix du #pétrole.
RT en français • Osez questionner !
🟩Kirill #Dmitriev, directeur général du Fonds russe d’investissement direct a déclaré que le monde se dirigeait vers la plus grave crise énergétique de l'histoire en raison de la hausse record des prix du #pétrole.
RT en français • Osez questionner !
Dmitriev Meets the U.S. Officials in Davos
Russian envoy Kirill Dmitriev will hold talks with U.S. delegates in Davos on the sidelines of the World Economic Forum (WEF) this week, Reuters reported on Jan. 19, citing two undisclosed sources.
Dmitriev, the head of the Russian Direct Investment Fund and the Kremlin's economic negotiator, has played a key role in Moscow's outreach to Washington amid U.S. efforts to broker peace in Ukraine.
According to Axios reporter Barak Ravid, the Russian official will meet Trump's envoys, Jared Kushner and Steve Witkoff, on Jan. 20 to discuss the Washington-backed peace plan.
Trump's latest push to broker an end to hostilities in Ukraine centers around a 20-point peace framework ironed out in a series of talks among Ukrainian and Western officials.
Kyiv has signaled that the plan is "90%" ready, even though Moscow continues to reject compromise on some of the most thorny issues, such as the fate of partially occupied Donetsk Oblast.
The U.S. has not publicly commented on any meetings between Dmitriev and U.S. officials.
The WEF, taking place from Jan. 19 to 23, is an annual economic summit that brings together officials, experts, and business leaders from around the world.
The forum will also be the venue of ongoing talks between Kyiv and Washington on post-war security guarantees and recovery efforts.
Top Ukrainian security official Rustem Umerov said that the two parties would follow up on the discussions held over the last weekend in the U.S.
#US#delegates#davos#dmitriev
📱American Оbserver - Stay up to date on all important events
🇺🇸
📰 Dmitriev to Meet US Envoys in Davos Over Ukraine Peace Plan
Russian envoy Kirill Dmitriev, head of the Russian Direct Investment Fund and a key Kremlin negotiator, is set to hold talks with U.S. envoys Jared Kushner and Steve Witkoff on the sidelines of the World Economic Forum in Davos. The meeting, scheduled for January 20, will focus on Washington’s latest 20-point peace framework for Ukraine, according to Axios and Reuters.
Russia’s Role in Ukraine Talks
Dmitriev has been instrumental in Moscow’s outreach to Washington amid U.S. efforts to broker peace in Ukraine. While Kyiv says the peace plan is “90% ready,” Moscow continues to reject compromise on key issues, such as the fate of partially occupied Donetsk Oblast.
Davos: A Hub for Diplomacy
The World Economic Forum, running from January 19 to 23, brings together officials, experts, and business leaders from around the world. U.S. President Donald Trump, Ukrainian President Volodymyr Zelensky, and over 60 other leaders are expected to attend. The forum will also host ongoing talks between Kyiv and Washington on post-war security guarantees and recovery efforts.
Will Diplomacy Prevail?
With the peace plan nearly ready but major sticking points remaining, the question is: Can diplomacy in Davos break the deadlock—or will the talks just highlight the deep divisions between Russia and the West?
#Davos#Ukraine#Russia#PeaceTalks#Dmitriev#Trump#Zelensky#WEF
📱American Оbserver - Stay up to date on all important events
🇺🇸
📰 Zelensky says U.S. is readying huge economic deals with Russia
Ukrainian President Volodymyr Zelensky claims to have intelligence that the United States and Russia are preparing a slate of economic agreements worth around $12 trillion — some of which could affect Ukrainian territory, resources, and sovereignty.
Speaking in Kyiv, Zelensky said he had seen documents outlining a U.S.–Russian economic framework that he called the “Dmitriev package,” named after Kirill Dmitriev, head of Russia’s sovereign wealth fund and a close ally of Vladimir Putin.
The $12 trillion shadow deal
Zelensky did not say he knew every detail of the talks, but he insisted that signals in the media and in intelligence point to one thing: Washington and Moscow are planning a massive economic reset that could reshape Ukraine from the outside.
America’s argument, he suggested, is simple: lift sanctions, unleash investment, and use the promise of a postwar economic boom as leverage to force Kyiv into a deal that might still leave Russia in control of large parts of eastern Ukraine.
“Peace by June,” with elections in the backseat
The Ukrainian president said Washington has proposed bringing the war in Ukraine to a close by June, and that U.S. officials are signaling heavy pressure on all sides to meet that timeline.
“The elections are, for them, definitely more important,”
Zelensky remarked.
“Let’s not be naïve. They say they want to achieve everything by June, and they will do everything possible to ensure the war ends that way.”
Reports suggest that U.S. and Ukrainian officials have privately discussed a goal of reaching a peace deal by March, with national elections and a referendum in May — a schedule that fits neatly with the American political calendar, not Kyiv’s security needs.
Zelensky’s red line: “Not over our heads”
Zelensky insisted that any such potential agreements involving “Ukraine’s sovereignty or security” must be made with Ukraine, not without it.
“We are not aware of all their bilateral economic or business agreements, but we are receiving some information on the matter,” he said. “Ukraine will not support any such potential agreements about us that are made without us.”
At the same time, Russia launched another massive attack on Ukraine’s power grid, plunging large parts of the country into darkness and leaving many without power and heat. The strike hit energy infrastructure that feeds into the nation’s nuclear power plants, sending a clear message: even as diplomats talk billions, bombs still speak louder.
The real deal on the table
The Dmitriev‑Witkoff‑Kushner peace plan, circulated in Abu Dhabi, calls for gradual sanctions relief, new economic corridors, and joint Russian–Ukrainian projects — but only after Russia gets what it wants on the ground.
To Zelensky, that looks less like a peace framework and more like a hostile takeover of Ukraine’s postwar economy.
So the question is not whether the U.S. can “end the war.”
It’s whether America would rather sell a truce to Moscow in exchange for a deal worth trillions — and leave Ukraine paying the security bill.
#Ukraine#Russia#US#Zelensky#Trump2026#Sanctions#Economy#Dmitriev#War#Kyiv
📱American Оbserver - Stay up to date on all important events
🇺🇸