Что делать если нужно поставить какую-то 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
Nullité des services français.
Les familles de tous les prisonniers du bateau #Madleen reçoivent des nouvelles de leur service consulaire national. Sauf les Français. Nos familles n'ont aucune nouvelle alors que la rétention illégale dure depuis près de 24h. Nous Insoumis sommes sans nouvelle aussi.
Malgré nos relances au plus haut niveau, on ne sait même pas où sont les détenus.
Les services français ont-ils seulement demandé à être mis en contact ? Comment dire l'ecoeurement que cela nous inspire ? Comment notre pays peut-il s'abaisser ainsi ? Pourquoi les citoyens français sont-ils traités comme ça par les dirigeants du pays ?
👉Partagez sur Twitter
-----------
On vous a transféré ce message ? Abonnez-vous au canal Telegram de Jean-Luc Mélenchon sur : https://t.me/JLMelenchon
Rumbo a Gaza
🇵🇸 | 12 voluntarios de todo el mundo que navegan en el #Madleen. Una misión para romper el asedio ilegal de Israel a Gaza y establecer un corredor marítimo popular. #FreedomFlotillaCoalition
Vía 📱@PiensaPrensa
Síguenos t.me/Epinforma🔁 comparte
Some snippets from Greta’s interview after being deported by Israeli authorities. Continue fighting for Palestinians in Gaza, including those in wider Palestine who are unlawfully imprisoned, including over 400 children.
#Madleen#IOF#GretaThunberg#FreedomFlotilla
Palestinians in Gaza are being starved, denied aid, genocided- and this is all on live stream and on our watch. A statement from Yasemin Acar, FFC volunteer on ‘Madleen’ who was kidnapped by IOF, forcibly taken to Israel and currently being held in detention is delivered by her brother J. Acar. This is the real story.
#FreeGaza#BreakTheSiege
#Madleen#EndTheGenocide
Our 'Madleen' was on a mission of urgency after a year of set backs, carrying baby formula, food, medicine, and basic humanity. Then came unidentified vessels, speedboats, quadcopters, and finally, Israeli soldiers. Francesca Albanese recounts what happened in real-time as she spoke to the crew live. She reminds us that 'Madleen' was a UK-flagged boat seized in international waters. Israel's interception is an act of piracy. Abduction is illegal, as is their siege, genocide, occupation and countless other war crimes across Palestine. So what makes a small, aid boat so scary for the Israeli occupation? According to Francesca Albanese: it is our humanity. It is everyone's defiance. It is our collective power to break the siege.
#BreakIsraelsSiege#EndTheBlockade#StandWithGaza#FrancescaAlbanese#Madleen
The Freedom Flotilla Coalition invites you to join us from May 30th to June 1st in Catania, Sicily, Italy, as we stand together in solidarity to launch our new mission, the ‘Madleen’.
The summit will be happening in Porto di San Giovanni li Cuti, where we will stand in solidarity with the Palestinian people in a series of panels, cultural programs, and community gatherings.
The ‘Madleen‘ will sail to break Israel's illegal siege as we bring humanitarian aid, hope, and solidarity to Gaza. The world stands united against the deliberate starvation, genocide, Apartheid, colonial occupation, and the ethnic cleansing of the Palestinian people. Join us!
Let's sail in spirit and solidarity. Free Palestine!
#FreedomFlotilla#BreakIsraelsSiege#EndTheBlockade#StandWithGaza#AllEyesOnDeck#Madleen#Conscience
Meet just some of the panelists, volunteers and supporters that will join us as we launch the ‘Madleen’ that will sail in a matter of days to break Israel's illegal siege of Gaza.
We urge media, press and supporters to join us in Catania, Sicily - your coverage and solidarity is critical in helping ensure our safety. March with us. Make noise with us. Show the world that Europe will not be silent. Share our content. Make it impossible for every politician, for the European Union and media to ignore what is happening in Gaza. Make it impossible for them to ignore the voice of the people, to ignore this mission, and to ignore this moment.
#BreakTheSiege#BreakIsraelsSiege#AllEyesOnDeck#EndTheBlockade#StandWithGaza#AllEyesOnDeck#Madleen#Conscience
Lara, speaking from Brazil, has had no contact with her husband, Thiago Ávila, since he was abducted and detained illegally by Israeli forces from the 'Madleen'. Since then, Thiago has been placed in solitary confinement, denied communication with his family.
According to Lara, Israeli authorities threatened Thiago with the psychological torment of isolation without light or ventilation. Despite this, Thiago remains on hunger strike, holding firm to his belief in justice for Palestinians and the right of every child to food, safety, and freedom.
From his prison cell, he wrote a letter to his 1-year-old daughter. Lara generously shares that with us today.
This is a call not just for Thiago’s release—but for the world to pay attention to Gaza, to Palestine, and to all people who are exploited, forced to live under occupation.
#FreedomFlotilla#Madleen#Thiago#IOF#WeWillSail#BreakIsraelsSiege#EndTheBlockade
Now with Israel's attack on Iran, the airports are shut down, and our three remaining 'Madleen' team members, Pascal Maurieras, Yanis Mhamdi, and Marco van Rennes may face an extra month, illegally detained in Israeli prison.
All three were meant to be released and flying back to their families today, June 13. The French and Dutch governments must find alternative routes and get their citizens home, whether through Jordan or otherwise - NOW.
Contact details in our slides and email template in our stories.
#BreakIsraelsSiege#EndTheBlockade#Madleen#WeWillSail#AllEyesOnDeck#StandWithMadleen#StandWithPalestine
Meet the 12 volunteers from around the world, who are sailing on 'Madleen' in the Freedom Flotilla Coalition's steadfast mission to break Israel's illegal siege of Gaza and establish a people's sea corridor:
Baptiste Andre 🇫🇷
Greta Thunberg 🇸🇪
Şuayb Ordu 🇹🇷
Mark van Rennes 🇳🇱
Omar Faiad 🇫🇷
Pascal Maurieras 🇫🇷
Reva Viard 🇫🇷
Rima Hassan 🇫🇷
Sergio Toribio 🇪🇸
Thiago Ávila 🇧🇷
Yanis Mhamdi 🇫🇷
Yasemin Acar 🇩🇪
Let their names be known, as they hold the people's hearts and courage, and carry solidarity to Palestinians in Gaza.
#AllEyesOnDeck#Madleen#Conscience#BreakTheSiege#EndOccupation#FreePalestine#FreedomFlotilla
The seizure, detention, and attempted deportation of the our team are clear violations of international law and Israeli law. They must be released immediately and unconditionally. We will not be silent. The blockade is illegal. Our mission remains: to break the siege and deliver aid to Gaza.
Artwork by Zina Zindah, 11 years old, during an art workshop by @maysaartist from Gaza.
#FreedomFlotilla#EndTheBlockade#Gaza#HumanRights#LetThemGo#Madleen#WeWillSail
Freedom Flotilla Official Update: It's time for our governments to do their jobs and sanction Israel. Its illegal attack on 'Madleen' while sailing in international waters is a small extension of their war crimes in Gaza. Governments, institutions, media, and corporations must stop protecting Israel, now. They must stop prioritising profit over human lives, now. Protect our volunteers while protecting Palestinians in Gaza and wider Palestine.
#BreakIsraelsSiege#EndTheBlockade#Madleen#FreedomFlotilla#Volunteers#IOF#StandWithGaza#StandWithPalestine