Что делать если нужно поставить какую-то 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
“Stop waiting for Israel’s permission.” Human rights lawyer and FFC volunteer @huwaidaarraf calls on the world to stop waiting on permission from a genocidal state. She explains that the Freedom Flotilla Coalition wasn't ever only about humanitarian aid - we are fighting for the liberation of the Palestinian people. And no matter what violence Israel commits against us or our ships, we won’t be silent while an entire population is deliberately starved and massacred. No one should. Join the movement. Help us break the siege.
Take action now: https://bit.ly/alleyesondeck
#FreedomFlotilla#BreakTheSiege#Gaza#HumanRights#DirectAction#Palestine🔽
‘Handala’ is due to depart, just weeks after ‘Madleen’ set sail to Gaza. In a time of unprecedented levels of global repression of Palestinian solidarity, with individuals having livelihoods and careers threatened for supporting Palestine, we are reminded that repressive tactics only work if people are bullied into silence.
The ‘Handala’ mission is only one part of a global wave of solidarity. Investigative group Forensic Architecture are making an online tracker to monitor the vessel’s passage publicly available online, as with the ‘Madleen’ mission. Every act of documentation and witnessing is part of holding Israel - and complicit governments- accountable.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
Lubna Tuma from Adalah Legal Centre provided us with a briefing on the status of the Flotilla members who were abducted from international waters by Israeli forces on 9th June 2025. Recorded just after leaving a legal counsel meeting held with the Flotilla volunteers in Givon prison, she comments on the numerous violations of human rights they were subjected to during the court hearing and in Israeli custody. Since recording Rima Hassan is no longer in solitary confinement. Please donate to Adalah Legal Centre today. QR code included and information provided at the end of the video.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
Baptiste André, Rima Hassan, Reva Viard and Pascal Marieras are on board the ‘Madleen’ which is fast approaching Gaza. According to the Israeli military and sources in Israeli media, the vessel is soon due to be forcibly intercepted, likely within 24 hours. The crew on the ‘Madleen’ call on the President of the French Republic to ensure their safe passage and to respect the sovereign rights of the Palestinian people over their own territorial waters. As signatory to the United Nations Charter, the Rome Statute, and the United Nations Conventions against Apartheid and Genocide, the French Republic is obliged to ensure their safe, unimpeded passage as they attempt to deliver humanitarian aid and do all that it can to end the genocide.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
As Israel threatens to attack the ‘Madleen’ as it sails towards Gaza, John Dugard, Professor Emeritus of international law and former UN Special Rapporteur on the situation of human rights in the Palestinian territories occupied since 1967, explains the illegality of an Israeli military intervention.
Volunteers onboard the ‘Madleen’ are urging people to pressure their governments to ensure their safe passage as they attempt to open a sea corridor to Gaza, especially as the situation on the ground there deteriorates.
The ‘Madleen’ and the civilians on board are protected by international law and any attempts to block them will constitute an unlawful act of aggression against a civilian vessel.
All Eyes On Deck.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
Dr Mohammed Mustafa joined the gathering of local and international supporters who gathered in solidarity as they bid farewell to the Madleen from Catania, Sicily. Having served on two medical missions to Gaza, Dr Mustafa has seen firsthand the devastation wrought on its healthcare infrastructure. Having witnessed the impact of the genocide, he outlines his hopes of establishing a children’s hospital in Gaza.
‘Everyone has to do their part. We all owe a responsibility to those people in Gaza.’
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
Actor Liam Cunningham was among a huge crowd of local and international supporters who gathered in solidarity as they bid the Madleen farewell from Catania, Sicily. He highlights the inaction of governments worldwide in response to overwhelming and unambiguous proof of Israel’s genocide being carried out in Gaza. In the context of government complicity in failing to uphold their obligations under international law, he reminds us that actual change is always driven by the people.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
Don’t Lose the ‘Madleen’: Track Her Journey to Gaza
In partnership with Forensic Architecture, we’ve equipped the Madleen with a live tracker to ensure safety, accountability, and global solidarity.
As she sails to break Israel’s illegal blockade of Gaza, the risk of attack is real. The tracker broadcasts her position in real time deterring violence, exposing any aggression, and allowing the world to witness this mission of resistance.
Through this collaboration, we are not only increasing transparency, we are building a framework for justice. The tracker transforms a solitary vessel into a globally witnessed journey, making it harder for any violations to occur unnoticed or unchallenged.
Follow the Madleen. Stay alert. Stand with Palestine.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
All eyes on Gaza. The 'Madleen' sets sail tomorrow, carrying humanitarian aid and unwavering solidarity. This is not charity. This is a nonviolent, direct action to challenge Israel’s illegal siege and escalating war crimes. From the river to the sea, amplify the voices of Palestinians demanding their human rights, including the freedom of movement, and self-determination. Demand your government safeguard our journey to Gaza, now.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege
📷 Actor, activist and 'Handala' crew member Jacob Berger reflects on the urgency of the Flotilla's mission to deliver life-saving aid to the Palestinian people of Gaza.
He affirms the importance of taking part in this mission as a Jewish American as a vital act of dissent, and hopes that the Flotilla will inspire more people to take direct action.
#FreedomFlotilla#Gaza#BreakTheSiege#AllEyesOnGaza#AllEyesOnDeck#DirectAction#EndTheBlockade#BreakIsraelsSiege#Handala