Что делать если нужно поставить какую-то 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
🗣Top Genres of Podcasts Among Avid Fans
More than 61% of American households have a fan of #podcasts in the music genre.
- 37 million of these households identify as avid fans;
- 24 million consider themselves casual fans.
🚀@PerspectiveIX
❓ Do you listen to podcasts?
#podcasts
Great, engaging and beneficial podcasts
Let's not forget, English podcasts are the kind of content that takes the least time for us to use.
You can make the most of your time by listening to English podcasts and revitalizing parts of the day that may be unused for whatever reason.
How to use podcasts⁉️
English podcast for fast language learning😍😍
🌟If you want to listen to the podcast as efficiently as possible, follow these steps:
🔰Listen to podcasts every day. Listen to podcasts daily and cultivate this habit easily.
Find podcasts that interest you. Ask yourself, "What podcasts should I listen to," and try to choose one that suits your interests.
🔰Listen to podcasts that have transcripts or text. This helps you find new words and phrases quickly in the text and understand the structure of different sentence types.
🔰After listening to the podcast with the text, in the next step try to do it without the text. This will strengthen your listening skills and help you to understand native English speakers more easily, even if they speak very fast.
🔰Do not despair if you listened to an English podcast and could not fully understand it. There are countless ESL podcasts designed for different levels, from beginner to advanced. Surely you can find a podcast that fits your level every day
@TowardDiscoveringEnglish
@TowardDiscoveringEnglish
@TowardDiscoveringEnglish
@TowardDiscoveringEnglish
This is the best foster mom in the world!
🔻Lynx Alyona lives in the Irkutsk Zoo, and she has a very strong maternal instinct.
🔻Over several years, she has already raised orphaned kittens, bear cubs, five puppies, and two Amur tiger cubs.
🔻Alyona makes sure the babies are well-fed, clean, and well-behaved.
🔻As soon as she hears the pitiful meows of abandoned babies, she understands: "Oh, these are mine!"
⏺Here are the🇷🇺(word stress)+🇬🇧texts for you to practice! https://telegra.ph/Podcast-07-04-2
❗️You can also send me the recording of your reading of the Russian text to @RCR_feedback_bot and get feedback!
#podcasts
#brief_and_interesting
😎RCR | Support | Boost
¿Que puede hacer este bot?
@podcastly_bot
Encuentre nuevos podcasts por sistema de búsqueda o recomendación, envíe notificaciones sobre nuevos episodios.
Idiomas: varios incluido español
(Visto en @botsgram_cu)
#podcasts#búsqueda
🎧About 1 in 4 Consumers Say They’ve Made A Purchase After Hearing A Podcast Ad
The US population has embraced podcasts, with the majority of Americans over the age of 12 years listening to them on a weekly basis. And, per a survey by Adobe, more than half (52%) of these #podcast enthusiasts are listening to #podcasts while commuting to work or while they are working.
Among the nearly three-quarters (72%) of respondents who report having heard an ad while listening to a podcast, 1 in 3 say the ads are more engaging than on other formats and 2 in 5 say they are less intrusive. This could be due to the type of ads heard on podcasts, as the majority of ads are still host-read, which aids in maintaining continuity within the podcast.
🦅@PerspectiveIX via MarketingCharts.
🎧The Steady Rise of Podcasts
Over the past decade, #Podcasts have seen a steady rise in popularity. According to Edison Research, 64% of Americans are now familiar with the term “podcasting” and more than 4 in 10 have listened to a podcast themselves.
The format’s rise in popularity clearly coincides with a general increase in digital media consumption, specifically on mobile devices. Also, #Podcast is the only format users can consume passively.
❗️You can start listening to some fantastic podcasts on📻@iXRadio.
🚀@PerspectiveIX via Statista.
❓How familiar are you with podcasting? I...
AI Podcasting Startup Raises $1.3M
Retellio secures $1.30 million in funding to develop AI agents that convert thousands of hours of customer calls into 30-minute podcasts. More details at Retellio's website.
#AI#Funding#Podcasts#Startup#CustomerExperience#Tech
А для всех тех, кто любит неспешно заниматься своими делами в ночной тиши под приятные беседы умных людей, у нас сегодня новый подкаст с канала Pam Grossman — "#156 - Loretta Ledesma, The Death Witch" c ведьмой смерти Лореттой Ледесмой.
Впрочем, разумеется, днём его слушать тоже можно.
Слушать по ссылке.
#podcasts
#witchcraft
#western_esoterism