Что делать если нужно поставить какую-то 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
News: #Amnesty flags impunity, forced eviction, and shrinking civic space in #Ethiopia’s 2025 human rights record
Amnesty International has raised alarm over ongoing human rights violations in Ethiopia, citing entrenched impunity, continued armed conflict, and a tightening grip on civic space throughout 2025.
“Impunity for past and ongoing violations persisted,” Amnesty said, pointing to systemic failures to investigate and prosecute abuses.
https://addisstandard.com/?p=56612
📰 NEWS | Venezuela: Rodríguez Hosts US Chargé d’Affaires Dogu in Presidential Palace
Venezuelan Acting President Delcy Rodríguez hosted US Chargé d'Affaires Laura Dogu in Miraflores Palace on Monday.
The meeting capped a lightning-fast diplomatic rapprochement following the January 3 US strikes and kidnapping of President Nicolás Maduro.
Days earlier, Rodríguez announced plans for an "amnesty law" to promote peace and coexistence in the country.
Follow the link to read the report: https://venezuelanalysis.com/news/venezuela-rodriguez-hosts-us-charge-daffaires-dogu-in-presidential-palace/
#Diplomacy#Amnesty#DelcyRodríguez#Imperialism
#Ethiopia: OLA outlines factual error in #Amnesty report; calls for independent investigation
The Oromo Liberation Army (#OLA) has rejected findings of a recent report by Amnesty International accusing its fighters of gang rape and sexual slavery against women in #western_Oromia, alleging that the report contains “serious methodological flaws and factual errors,” and calling for an independent investigation into abuses committed in the region.
In a press release issued on 06 March, the OLA said that while it condemns all forms of gender-based violence and supports efforts to document abuses against civilians, Amnesty’s report titled “No One Came to My Rescue” suffers from investigative shortcomings & fails to conclusively identify the perpetrators of the crimes described.
The armed group argued that Amnesty itself acknowledged in the report that it could not verify the identities of the alleged perpetrators at the time of publication, a point the OLA said..
Read more: https://addisstandard.com/?p=55634
Dear Members,
You would observe that NIDO Russia has not taken part in disseminating any news on amnesty. Observant people have called privately to inquire and we have guided them as usual. Some have taken matters into their hands and are suffering the consequences, not one, not two. Please before you rush, it may be useful to contact executives in the organisations that you belong. Don't fall prey to ambiguity.
A word is enough for the wise.
Have a beautiful day ahead!
Dr. Godwin Ibe
https://t.me/nido_russia/1936
#migration#nidorussia#amnesty#Nigeria#russia
#Ethiopia: OLA fighters accused of gang rape, sexual slavery against women in #Oromia, Amnesty report
#Amnesty International has accused fighters of the Oromo Liberation Army (#OLA) of committing gang rape, sexual slavery, and other abuses against women and girls during the ongoing armed conflict in Ethiopia’s Oromia region, warning that the violations have contributed to mass displacement and long-term trauma for survivors.
In a new briefing titled “No One Came to My Rescue: Gang Rape, Sexual Slavery, and Mass Displacement of Women in Oromia, Ethiopia,” the rights group said it documented 10 cases of sexual violence in the #Sayo and #Anfillo districts of #Kellem_Wallaga zone, areas it described as strongholds of the OLA.
Amnesty said that the conflict between the OLA and Ethiopian government forces — including the #ENDF, Oromia #Special_Police, Oromia regional police, and local militias — meets the threshold of a non-international armed conflict under .....
Read more: https://addisstandard.com/?p=55611