Что делать если нужно поставить какую-то 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
Overcoming The Fear Of Public Speaking
Many of us feel nervous, shy, break into sweat or fear the thought of public speaking. Did you know that public speaking is among the most feared activities in the world? Some of us feel it is not our strength and fear being judged. Public speaking is an essential skill to effectively convey what we want to.
1. Your thoughts, feelings, personality, values – they are all a packet of your energy called vibrations. These vibrations reach people before your words. They are the first level of your communication with others. So keep them pure.
2. Meditation and daily study of spiritual wisdom every morning keeps your thoughts clean and less. When you start thinking right and positive, you will no longer need to be careful with your words. You will speak what you think, believe and live by.
3. Focus on conveying the message, not on impressing your listeners. Do not compare or compete with others. Stand by the truth, untouched by people’s opinion.
4. Visualize yourself respectfully sharing what is in your inner consciousness - your wisdom, skills, views or experiences with a selfless intention of giving. Visualize people who receive your message getting positively influenced.
#Fear
Arachnophobia or the fear of spiders is the oldest and most common phobia in the Western culture. The word Arachnophobia is derived from the Greek word ‘arachne’ meaning spiders.
🕷🕸
[Learn more]
@googlefactss
#spiders#fear#HumanMind
Phobia is an intense, irrational fear of something that is often not dangerous. Fear is a normal reaction to real danger or threat. Phobias cause strong anxiety that is much bigger than the actual risk and can disrupt daily life. Fear helps keep us safe, but phobias are more about worry and avoidance even when there is little or no real danger.
@googlefactss
#Phobia#Fear#Anxiety#MentalHealth😨⚠️
Fear or opportunity?
Fears are the body's adequate reaction to something new, to something that once caused unpleasant consequences, or to something that directly or indirectly threatens one's life.
But there are fears that simply must be overcome. For example, if you have an idea, but to implement it, you do not have the courage, and therefore and perseverance.
It is behind such fears that lies your invaluable potential. The body never generates ideas that it doesn't have the resources to implement. Our thoughts are not random. Think of the opportunities that will open up before you after you overcome your fear. Have you imagined it? Now act!
Join us for more -> @ipersonalgrowths💡
#MentalGrowth
#Fear
#opportunity
#psychologyinformation
Watching a scary video before seeing abstract art makes people feel the art is more powerful and awe-inspiring.
Fear grabs the attention and makes us focus on what we see.
🎨👻
[Read more]
@googlefactss
#Art#Fear#Psychology#Sublime#Creativity
Hello everyone! 24 hours left until our next Kucoin pump. The market looks very good and our power is growing every day. We expect a massive volume and profits tomorrow.
This is a brief explanation of what will happen during our pump:
1) When the coin is announced, we buy it together, as a team.
2) This initial push triggers buying from trading algos, MM bots and generally – outsiders.
3) As the outsider buy orders further increase the price, we begin to slowly sell way higher than where we bought.
Full guide can be found in the previous messages. Here are the results of our latest pumps:
#HIP → 2400%
#QUICK → 1500%
#BONDLY → 800%
#FEAR → 750%
#VEMP → 750%
IMPORTANT: We are the original and longest running pump group. Please ignore all ads in this channel as they are not approved by us, we do not endorse any other channels. All other alleged "pump" groups are copycats trying to capitalize on our success, reputation and care for members.
Hello everyone! Exactly 24 hours left until our next Kucoin pump. The market looks very good and our power is growing every day. We expect a massive volume and profits tomorrow.
This is a brief explanation of what will happen during our pump:
1) When the coin is announced, we buy it together, as a team.
2) This initial push triggers buying from trading algos, MM bots and generally – outsiders.
3) As the outsider buy orders further increase the price, we begin to slowly sell way higher than where we bought.
Full guide can be found in the previous messages. Here are the results of our latest pumps:
#HIP → 2400%
#QUICK → 1500%
#BONDLY → 800%
#FEAR → 750%
#VEMP → 750%
IMPORTANT: We are the original and longest running pump group. Please ignore all ads in this channel as they are not approved by us, we do not endorse any other channels. All other alleged "pump" groups are copycats trying to capitalize on our success, reputation and care for members.
K-k恐k惧j拉l斯s维w加j斯s- 恐惧拉斯维加斯 Fear and Loathing in Las Vegas (1998)
直达链接:https://pan.quark.cn/s/41140f577da4
#恐惧拉斯维加斯#赌城风情画
#Fear and Loathing in Las Vegas
#赌城情仇#拉斯维加斯的恐惧与嫌恶
链接:https://link3.cc/sf_com
#电影#喜剧#美国#90年代