Что делать если нужно поставить какую-то 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
👉Signs of Cheating👈
If you’re already thinking that cheating might be present in your relationship, chances are it is. While there’s no clinical diagnosis that can uncover whether or not your partner is cheating, there are several signs that could mean infidelity is there.
Here are 10 well-known signs of cheating:
📌 Protectiveness With Electronic Devices
Partners engaged in infidelity often cheat over the internet, either on their computer or phone. If your partner is overly protective of their electronic devices or defensive about spending time on them, that might mean they don’t want you to know who they’re talking to.
📌 Periods of Unreachability
There might be times when your partner simply disappears and you have no clue where they are. That might mean that they are with someone they don’t want to tell you about.
📌 Different Levels of Sexual Interaction
While you might think that a person who is cheating would have less time for sex with their partner, this isn’t necessarily true. For some people, cheating actually causes them to feel sexually energized and suddenly start to seek out more frequent or different kinds of sex with the person they’re cheating on.
📌 Inconsistent Explanations
Lying is much harder than many people understand, especially constant lying to a committed partner. While liars will do their best to repeat the same story each time they lie, they usually start to give inconsistent information when under stress or if asked the same questions in a way they’re not used to.
If your partner gives conflicting explanations for where they are, what they’re doing, or how well they know someone who you suspect they’re cheating with, this could be because they’re having difficulty keeping their lies consistent.
📌 Altered Schedule
If working late is suddenly a new normal even though your partner’s job doesn’t really require it, they may not be telling the truth about where they are.
#part1
🧪⚜️ CORONA VOCAB 2019-20 ⚜️🌡
🦋 English grammar & Vocab 🦋
#Part1
🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸
🦠 Acute respiratory stress syndrome (ARDS)
✔️a condition in which fluid builds up in the air sacs of the lungs. The fluid prohibits the lungs from getting enough air, leading to a deprivation of oxygen in the bloodstream. The condition is often fatal.
🦠 Asymptomatic
✔️presenting no symptoms of disease. In the case of COVID-19, this means absence of fever, dry cough, sore throat, shortness of breath and body aches, among other less common symptoms. Notably, it is recommended that individuals do not get tested unless they exhibit symptoms because of the risk of false negatives. In other words, most tests will not be accurate unless symptoms are present.
🦠Case fatality rate
✔️ the ratio of deaths from COVID-19 to the total number of individuals diagnosed with the disease.
🦠Clinical trial
✔️ research experiments on human participants designed to answer questions about new treatments; in the case of COVID-19 and coronaviruses, the safety and efficacy of a potential vaccine.
⭐️@TowardDiscoveringEnglish⭐️
Культура кофе #part1
Так как я жуткий кофеман, я не могу не написать про кофе с кардамоном. И вообще про культуру кофе.
Арабы никогда не зальют кофе для турки просто кипятком и размещают ложкой в кружке. Это кощунство по мнению арабов! Кофе обязательно нужно сварить в турке. Если вы говорите «قَهْوَة سادة», это значит, что в кофе не будет сахара от слова совсем. Если вы промолчали, то автоматически вам принесут кофе с сахаром. Будьте готовы, что арабы кладут сахар от души, поэтому скорее всего вы будете пить сахар с кофе, а не кофе с сахаром.
Продолжение следует.
Хештег #арабскийкофе
✨ Opportunity you're missing!#part1
Freshman Academy is now providing free classes with an experienced methodology for students preparing for the Standarized tests (SAT), English level test, or willing to boost their English comprehension & communication.
You can join classes through registering to the Education Lab and will get access to attend-free lessons.
#opportunities
A Day at the Rangein Poland: My First Glock Experience (Part 1)
I don't know how I got interested in shooting or guns but maybe after watching this video, I started watching more about guns. Somehow I developed habit to see videos about assembling, aiming, how it works type of videos. One day, I was talking with my friend about multi-sport, app that gives access a lot of sport activities. So I saw there was a section called "Shooting Range". I got hooked. Since then I was thinking to go there.
#part1#story