Что делать если нужно поставить какую-то 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
#Kenya Unveils New Model to Turn #Embassies into Deal-Making Hubs
Kenya has introduced a new digital trade model for economic diplomacy through the launch of BiasharaLink and Deal House in Ethiopia.
In a press statement on February 12, Prime Cabinet Secretary and Cabinet Secretary for the Ministry of Foreign Affairs, Musalia Mudavadi, stated that the new digital platforms were developed by Real Sources Africa to help embassies serve as active trade hubs that originate, verify, and execute cross-border deals.
The new trading models are developed by Real Sources Africa, Kenya’s designated trading company for the African Continental Free Trade Area (AfCFTA).
According to Mudavadi, BiasharaLink is designed to enable diplomatic missions, exporters, investors, and market actors to formally capture, structure, and track trade and investment opportunities aligned with the priorities of the AfCFTA.
https://thekenyatimes.com/business/money-markets/kenya-unveils-new-model-of-economic-diplomacy-in-ethiopia/
#Ethiopia: Tigray health bureau issues urgent appeal warning of imminent #health system collapse amid fuel, medicine shortages
The #Tigray Interim Administration’s Bureau of Health has issued an emergency appeal to humanitarian partners, donors, #UN agencies, #embassies, and global health institutions, warning that the region’s health system faces an imminent operational collapse due to severe fuel shortages, a halt in pharmaceutical supplies, and mounting financial restrictions.
In the appeal dated 05 March 2026, the bureau urged immediate international intervention, stating that millions of civilians’ risk preventable illness and death if lifesaving services cannot resume.
“Immediate intervention is required to prevent avoidable morbidity and mortality among millions of civilians,” the bureau said in the appeal.
The bureau said that health care must remain protected under international law and should not be restricted by political considerations..,,,,
Read more: https://addisstandard.com/?p=55597
🛰 Embassies Shut, Airspace Closed: Trump’s “Four-Week” War Goes Regional
Trump promised a four–five week air war. By day four, U.S. embassies are shuttered and the sky over half the region is basically a no‑go zone.
Iran’s retaliation has gone wide: at least five Gulf allies report drone and missile strikes, including hits around U.S. diplomatic facilities, pushing Washington to close its embassies in Saudi Arabia and Kuwait and temporarily halt operations in Beirut. Airspace is now closed or heavily restricted in at least six countries — Iran, Iraq, Kuwait and others — as aviation authorities extend bans on civilian traffic amid “ongoing security concerns.”
Israel is still escalating. It claims fresh strikes on “high‑profile” targets in Tehran, including the presidential office, while also pushing ground troops deeper into Lebanon as Hezbollah answers with missiles and attack drones. Smoke over Beirut’s southern suburbs is the new backdrop to every “we don’t want an endless war” sound bite.
Meanwhile, the body count keeps climbing. The Pentagon now acknowledges six U.S. service members killed with more casualties expected. Iran’s Red Crescent reports hundreds dead across more than 150 cities; Lebanon’s health ministry counts dozens of fatalities; Israel and Gulf states are adding their own numbers to a regional tally that has already broken 800 in under a week.
And Trump, facing diplomats evacuated, embassies hit by drones, and airspace slammed shut, is already revising his own timeline — hinting U.S. forces can keep striking Iran “far longer” than the four–five weeks briefed by the military. The war was sold as a controlled burn. It’s behaving like what it is: an open fire in a room full of fuel, with the exits locking behind the people who were told this would be quick.
#Iran#Trump#Israel#Lebanon#Hezbollah#embassies#airspace#war#MiddleEast
📱American Оbserver - Stay up to date on all important events
🇺🇸