Что делать если нужно поставить какую-то 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
🖊OPINION | Hugo Chávez: Truth as a Form of Struggle
Former Vice President Elías Jaua reflects on the political style of Hugo Chávez, highlighting moments when the Venezuelan leader publicly explained major decisions and setbacks, from acknowledging the defeat of the 2007 constitutional reform referendum to announcing his cancer diagnosis on national television in 2011.
Read the full opinion piece here: https://venezuelanalysis.com/opinion/hugo-chavez-truth-as-a-form-of-struggle/
#HugoChavez
📝 INTERVIEW | Building Communal Hegemony: A Conversation with Robert Longa
El Panal Commune’s main spokesperson talks about how communes might enter the Venezuelan constitution through an upcoming reform.
🔗 Read more in the latest VA interview here: https://venezuelanalysis.com/interviews/building-communal-hegemony-a-conversation-with-robert-longa/
#Communes#HugoChavez
#USImperialism
🎥 VIDEO | Chávez the Radical XXIX: ‘You Are Not Small Businesspeople’
One of the goals of capitalist ideology is to hide or downplay class struggle. Instead, it seeks to foster individualism over collective processes.
Former Venezuelan President Hugo Chávez looked to dispel these myths in a 2012 speech, reminding those who take part in the informal economy that they are not small businesspeople but belong to the working class.
👉 Watch the full video here: https://shorturl.at/D1IgI
#HugoChavez#ChaveztheRadical
In the latest VA interview, Joel Suárez, a theologian from Cuba’s Martin Luther King Center, shares personal reflections on Hugo Chávez’s spiritual journey as a revolutionary man of faith, including his historic 1994 meeting with Fidel Castro. Suárez underscores the role of Liberation Theology in Chávez’s revolutionary praxis.
Read the full interview here: https://venezuelanalysis.com/interviews/chavez-spirituality-and-revolution-a-conversation-with-joel-suarez-part-i/
#HugoChavez#Religion
🗒️🗣️ INTERVIEW | ‘The Imperialist Offensive is Nothing New for the Bolivarian Revolution’: A Conversation with Ana Maldonado
In the latest VA interview, Ana Maldonado — sociologist and coordinator for the Francisco de Miranda Front — discussed Washington’s renewed military escalation in the Caribbean. She warned that around 10,000 US troops are currently stationed in the region, signaling a revival of the Monroe Doctrine and a direct threat to Latin American sovereignty.
Despite this, Maldonado stressed that Venezuelans continue their daily routines with calm and organization. “We are in a phase of maximum preparation,” she said, noting that millions have voluntarily joined the Bolivarian Militia to defend the homeland.
🔗 Read the full interview here 👉https://venezuelanalysis.com/interviews/the-imperialist-offensive-is-nothing-new-for-the-bolivarian-revolution-a-conversation-with-ana-maldonado
#AntiImperialism#HugoChavez#USMilitaryThreats
📑🖊 OPINION | Socialist Communes and Anti-Imperialism: The Marxist Approach
Chris Gilbert analyzes when a commune or communal project can be considered anti-imperialist, drawing on Marx’s theoretical foundations.
One expression of this framework came in 2024. According to Gilbert, it was exemplified when Palestinian revolutionary Leila Khaled visited the El Panal Commune in Caracas. She praised it as a concrete example of sovereignty under U.S. sanctions, drawing parallels with the Palestinian struggle for national liberation. That same year, Venezuela also deepened its communal strategy by launching quarterly consultations and expanding public funding to strengthen commune powers.
Read the full opinion piece here: https://shorturl.at/eThgJ
#antiimperialism#Communes#HugoChavez
📝 INTERVIEW | Chávez and the Sowing of Values: A Conversation with Ana Sofía Cabezas
🗣 “We want future generations to know the Chávez we knew, not the one on Wikipedia.” The vice president of the Hugo Chávez Foundation, Ana Sofía Cabezas, speaks to Venezuelanalysis about the work being done to preserve and transmit the Comandante’s legacy.
She explains how Chávez’s values—humility, responsibility, sovereignty—can still guide younger generations, and why maintaining access to this history is essential: “Just as capitalism and imperialism continue to exist, Chávez’s project remains valid and useful to confront reality and envision the future.”
🔗 Read the full interview here 👉🏽venezuelanalysis.com/interviews/chavez-and-the-sowing-of-values-a-conversation-with-ana-sofia-cabezas/
#HugoChavez#HugoChavezLegacy
The Pancha Vásquez commune in Apure State, Venezuela, consisting of fourteen communal councils, embodies the region's deep-rooted traditions in agriculture and cattle rearing.
It's also where Hugo Chávez sharpened his political vision from 1985-1988, intertwining his socialist ideals with the local folklore. From the legendary “El Silbón” to “La Sayona,” the tales Chávez encountered in Elorza have become a vital part of the area's folklore, reflecting the enduring impact of his legacy.
Read the full interview here 👉🏼shorturl.at/jaxwE
#communalresistanceseries#communes#HugoChavez
Israeli strikes in Rafah have killed dozens of displaced persons, including small children. Chávez's unwavering condemnation of Israel's genocide against Palestine resonates now more than ever.
#RafahMassacre#HugoChavez
https://www.youtube.com/watch?v=ZR6UkNU32aA
🖊OPINION | One Hundred Years of British Interference in Venezuela
Declassified UK documents detail how British governments sought to protect oil investments in Venezuela for over a century, including opposing nationalisation and lobbying during Hugo Chávez’s presidency in 2001.
Read the full opinion piece here 👉🏽https://venezuelanalysis.com/analysis/one-hundred-years-of-british-interference-in-venezuela/
#HugoChavez#PDVSA#UnitedKingdom
🖊OPINION | Hugo Chávez Predicted This
US attacks against the Bolivarian Revolution did not begin on January 3, 2026.
In this essay, Nuvpreet Kalra traces the different stages of US efforts to undermine Venezuela's revolutionary process and bring about regime change.
Click here to read the article: https://venezuelanalysis.com/analysis/hugo-chavez-predicted-this/
#HugoChavez#Imperialism#NicolasMaduro#Sovereignty
🗓️ MILESTONE | On July 28, we remember the birth of Hugo Chávez, born in 1954 in Sabaneta, Venezuela.
A revolutionary leader who reshaped the nation’s political landscape, Chávez remains a defining figure in Latin American history and a lasting influence on global struggles for socialism, sovereignty, and social justice.
👉 Find out about his legacy in this infographic: https://venezuelanalysis.com/infographics/15574/
#HugoChavez#Socialism#Venezuela#LatinAmerica