Что делать если нужно поставить какую-то 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
Introducing VPN Apps category in Telegram Apps Center
Exciting news for all who prioritize online freedom: today we've added a new section in our catalog — VPN Apps. Now, it is easier than ever to activate a VPN connection directly within Telegram, ensuring your online activities remain private and secure.
The category currently features eight VPN services and their number will only grow! You can either choose from the highlighted options or click «See All» to explore the full list of VPN mini-apps to find the one that best meets your needs.
Dive into the VPN Appssection to enhance your online independence. Explore the world without boundaries, all from the convenience of your favorite messaging app.
#updates
#updates
Hey everyone! I have a major update with regard to all that I owe. I just wanted to completely compile my large list (besides Kiki thank-you headshots, kofi sketches, and fursuit work, for now) so that I can be transparent about the major list work that I owe and give a perspective of how much I'm juggling. Here it is; and I apologize for becoming so backlogged. It is really embarrassing, and I feel ashamed, but I genuinely can't help what life throws at me. I just hope that's a valid reason. Thank you ALL for being incredibly patient, understanding, and supportive despite this. I am so grateful beyond words.
#updates Hey everyone!
I've been going through the ringer lately and I apologize for slow progress and halted work on list comms.
Lately I've been just trying to raise money for Kiki, take care of Wiggles, and tend to my boyfriend and myself.
Earlier this evening, I learned that my aunt doesn't have much longer to live, so I'm understandably upset and concerned. She has been struggling with Parkinson's and injuries for the past year, but her condition worsened over the last couple days.
Just wanted to keep you all in the loop, because this will definitely affect everything work wise. I'm visiting her for probably the last time early next week with my boyfriend and dad.
I'll keep you all posted. Would you prefer updates here or Twitter? I'd love some feedback on that so I can reach people better and make sure these sorts of messages are delivered.
Thanks everyone for your kindness, patience, love, and support.
Hey everyone! I am so sorry for lack of updates this week. #updates
I've been going through the ringer lately. Just trying to survive day to day mostly. My head hasn't been right and my heart hasn't been well. Today was extremely bad in terms of my housing situation, so I'm thinking of taking it relatively easy until I get my heart re-checked next Wednesday.
After that and probably some medication adjustments, I should probably be good to go. I just don't want anything bad to happen since heart disease runs in my family and I live in a very high stress environment as it is.
Thank you all for understanding. There are good things on the horizon; I just need to make it there first.
#updates Hey all!
Bit of a health update and how it's affecting everything.
Lately my memory and cognitive function/abilities have been poor and lackluster. I'm rather overwhelmed in my daily life and I think that's what's contributing, along with my mental illnesses too.
I've been having a lot of trouble with processing, memory, anxiety, heart palpitations, and stress.
I am still trying my best to do work as I can however, and I see my two main doctors for physical and mental health on the 1st and 2nd of Aug. So, there are promising solutions on the horizon.
But, even so, I am concerned for my well being right now. Constant stress is never a good thing, and living in this environment has been extremely painful.
I think ultimately I'll be all right - I'll be taking it easy and working as I can until my appointments. Thank you all for your understanding, patience, support, love, and kindness. It makes me feel so happy and hopeful.
I'll talk to you all soon. 💙
Hi everyone!
I wanted to give an update. I apologize for the radio silence here and everywhere, mostly. I've been having some issue with stress and it's been taking a toll on my heart and sleep. My heart has been going fast and has been hard to calm down recently and I have been getting little/bad quality sleeps.
I'm mostly just trying to make it through my days and nights and take care of my heart and anxiety. I'll be doing work as I can!
But good news is, I see my doctor in a couple of weeks to reevaluate my heart condition and hopefully I can get some relief.
Thank you all so much for your patience and understanding. I want to continue to make art well into the future but I gotta listen to my body to make sure I can ensure that. #updates
#UPDATES💜#BTS
BTS WORLD TOUR ARIRANG💜
MEXICO CITY D-3 FULL CONCERT 💜
❌ DON'T COPY❌
• Don't Re-upload without
credits 💗
• Forward With Channel Tag ✅
:·.✧ ┋ @ashkookie_btsedit ┋✧:·.
┋✧:·. Main Channel: @letjungcook70 ┋✧:·.
#UPDATES💜#BTS
BTS WORLD TOUR ARIRANG💜
EL PASO D-2 FULL CONCERT 💜
❌ DON'T COPY❌
• Don't Re-upload without
credits 💗
• Forward With Channel Tag ✅
:·.✧ ┋ @ashkookie_btsedit ┋✧:·.
┋✧:·. Main Channel: @letjungcook70 ┋✧:·.
#UPDATES💜#BTS
BTS WORLD TOUR ARIRANG💜
EL PASO D-1 FULL CONCERT 💜
❌ DON'T COPY❌
• Don't Re-upload without
credits 💗
• Forward With Channel Tag ✅
:·.✧ ┋ @ashkookie_btsedit ┋✧:·.
┋✧:·. Main Channel: @letjungcook70 ┋✧:·.