Что делать если нужно поставить какую-то 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
Venezuelan Interior Minister Diosdado Cabello announced the arrest of a US Navy SEAL and two Spanish citizens, accusing them of plotting to assassinate President Nicolás Maduro. Authorities also seized 400 firearms and uncovered plans to attack key infrastructure. The US has denied involvement, calling the claims "categorically false."
Read the full report here 👉🏼https://shorturl.at/VIMCG
#Opposition#USVenezuelaRelations
Anatomy of Political Opposition in Ethiopia: Motives, Destinations, and Reasons to Reject or Accept Them. Read more.
https://borkena.com/2025/11/17/anatomy-of-political-opposition-in-ethiopia-motives-destinations-and-reasons-to-reject-or-accept-them/#Ethiopia#opposition#politics
Dear opposition politicians, Stop Illusion and Do the Real Work. Read. https://borkena.com/2025/11/07/ethiopia-dear-opposition-politicians-stop-illusion-and-do-the-real-work/#Ethiopia#opposition#politics
Before departing for Spain, Edmundo González signed a letter acknowledging the judicial ruling that confirmed Nicolás Maduro's victory. Later, the European Parliament passed a symbolic, non-binding resolution declaring González as Venezuela's "legitimate" president.
Read the full report here: https://shorturl.at/8cqhl
#Opposition#presidentialelections2024
Edmundo González, the US-backed opposition presidential candidate in Venezuela, has fled the country and arrived in Spain.
He sought refuge in the Spanish Embassy in Caracas before being granted safe passage by Venezuelan authorities. An arrest warrant had been issued for him last week, charging him with conspiracy and other crimes.
Read the full report here 👉🏼https://shorturl.at/BzsoN
#PresidentialElections2024#Opposition
Venezuelan authorities have issued an arrest warrant for former opposition presidential candidate Edmundo González on multiple charges, including forgery and conspiracy. The move comes after González refused to respond to summonses and amid his claim of electoral victory.
Full report 👉🏼https://shorturl.at/LTiS9
#Opposition#PresidentialElections2024
Venezuelan authorities have arrested two associates of opposition leader María Corina Machado, alleging a plot to incite violence similar to the 2014 and 2017 protests. The arrests aim to prevent attacks on military installations and energy companies.
Full details here 👉https://bit.ly/3IPfGlA
#opposition#presidentialelections2024
10 Ethiopian Opposition Parties Set Preconditions For Participation in the 7th General Election. Read.
https://borkena.com/2025/11/13/10-ethiopian-opposition-parties-set-preconditions-for-participation-in-the-7th-general-election/#Ethiopia#News#politics#Opposition
Despite María Corina Machado's bold claim, "There will be no elections without me!" the majority of opposition factions are committed to moving forward, concentrating on offering viable alternatives for Venezuela's presidential elections.
Don't miss out on the latest VA column from Clodovaldo Hernández. Click here to read more 👉🏽https://bit.ly/3OSlfD1
#Venezuela#opposition#presidentialelections2024
📑🖊 ANALYSIS | Venezuela in 2025: Unexpected Turns Mark the Start of the Political Year
VA columnist Clodovaldo Hernández reflects on recent events in the Trump II era and examines their impact on Venezuela’s opposition.
Trump’s second term has taken an unexpected turn regarding Venezuela. His special envoy, Richard Grenell, met with Nicolás Maduro in Caracas and facilitated the return of six U.S. citizens imprisoned in Venezuela. Meanwhile, USAID funding for opposition parties, NGOs, and media has been suspended for three months, triggering internal disputes.
🔗 Read VA’s latest column here: https://shorturl.at/Ek5T1
#DonaldTrump#Opposition#USVenezuelaRelations
🎙 Episode 31 of the VA Podcast is live: Is Edmundo González ‘Guaidó 2.0’?
The Venezuelanalysis podcast tackles the proverbial million-dollar question everyone is talking about: is the Trump administration about to do a rerun of the “interim government,” this time with Edmundo González in place of Juan Guaidó?
Host José Luis Granados Ceja is joined by fellow VA writer and editor Ricardo Vaz to talk about the different scenarios, sanctions and the economic balancing acts the Maduro government is facing.
Watch the full episode: https://www.youtube.com/watch?v=Nvrvw4M2jqo
#DonaldTrump#opposition#sanctions
In an opinion piece by Smolarek and Alexandra, they reveal how the US-led narrative of electoral fraud in Venezuela aims to delegitimize the government. Despite scrutiny, Venezuela remains steadfast in upholding democracy amid external pressures.
"After years of political instability caused by right-wing plots to overthrow the democratically elected government and even assassinate the leader, the Venezuelan government has pursued a straightforward principle." highlights the article.
Read more here: https://venezuelanalysis.com/analysis/venezuelas-election-in-the-crosshairs-of-new-us-regime-change-scheme/
#NicolasMaduro#opposition#presidentialelections2024