Что делать если нужно поставить какую-то 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
#Topic: 📌🏙Town and City🌆📌
Ten useful collocations, phrasal verbs and expressions for speaking (+definitions)
🖇to close down~ to stop doing business
🖇to get around ~ to travel around
🖇high-rise flats ~ multi-story apartments
🖇office block ~ a large building that contains offices
🖇pavement cafe ~ cafes with tables outside on the pavement
🖇residential area ~ an area where people live
🖇shopping malls ~ large indoor shopping centres
🖇sprawling city ~ a city that has grown over time and which covers a wide area
🖇upmarket shops ~ expensive fashionable shops
🖇public spaces ~ areas in a town or city that are open to the public
Prepared by Mr Andrews
👉@IELTS_with_Steven👈
🔹Obstacle: a thing that blocks one's way or prevents or hinders progress.
🔹Breakthrough: an important development that may lead to an achievement or agreement (make/achieve a breakthrough)
🔹Scrape through (an exam): only just succeed in passing an exam.
🔹Make a go of sth: (inf) make sth succeed specially a business or marriage
➕➕➕➕➕➕➕➕➕➕➕
⚜Tellus about your experiences in this regard and try to use the abovewords and expression in your writing.
#Topic
#Teamjimmy
@Sirjimmy
🔸Outstanding (adj) exceptionally good.
🔹Bias (n) A concentration on or interest in one particular area or subject.
🔸To rise to stardom (expression): to become famous.
🔹Public figure (n): a well-known and notable person.
🔸Paparazzi (n) a freelance photographer, especially one who takes candid pictures of celebrities for publication.
➕➕➕➕➕➕➕➕➕➕➕
⚜Tellus about your experiences in this regard and try to use the abovewords and expression in your writing.
#Topic
#Teamjimmy
@Sirjimmy
🎙🌀 Speaking Activity 🌀🎙
Genetic engineering is an important issue in modern society.
Some people think that it will improve people’s lives in many ways.
Others feel that it may be a threat to life on earth.
⚜️Please discuss on both opinions and tell us about your experiences in this regard.
#Topic
#speaking
#Essay#IELTS
#Teamjimmy
@Sirjimmy
It is an educational group for English learners of different levels, from beginners till advanced( who speak fluently). How we practice English here: 1) 👩🏫”every”day SPEAKING topic is pinned,to find it here press #topic.To take part in it, find the topic, press on it- reply and answer the questions by giving the full answer (not short), essay or a speech presentation by recording your voice, then tag admins or some members who can check your pronunciation or grammar mistakes. You can also find here a speaking partner and practice together by exchanging different opinions, healthy debates, ask extra questions . 2) 👨🏫 LISTENING skills (quiz) press #test_of_theday or #listening_quiz or #audio 3)👩🏫learn and make sentences with new IDIOMS and WORDS of the day, press #idiom_of_the_day#test_of_the_day or #word_of_the_day. Whenever u need some GRAMMAR tips press #grammar_in_brief, SPELLING press #spelling or #common_mistakes4) On Sundays PRONUNCIATION class at 7pm Iranian time. The host is an American professional university teacher- Fatima g. 5) 👩🏫for any assistance ask ADMINS @SB838@Scud21 6) 👨🏫read and record in order to practice your PRONUNCIATION skills and fluency press #readrecord. Press reply, read text and record your voice 7) 👩🏫 Don’t forget to check our GROUP FILES files- downloaded books, curriculums, useful information( music, vocal messages of other members,photos), 8) 👨🏫 CHAT with people from Ireland, Iran,Yemen, India, Brazil,Uzbekistan, Iraq, , Indonesia, Korea, Africa, Turkey, UAE etc. and practice your English. Try to start your conversation politely with a neutral phrase: Hello guys, I’m...... a new member, from...... Nice to meet you. 9) 👩🏫 when we have some free time, we play a game which is called- Crocodile 🐊- when one member is a host who sees the word, gives some hints( explains this words without naming it) and other members guess the word by typing it in chat. So you can practice reading , listening, writing, grammar, speaking
#Start#contents#index#mark
This channel publishes groups and channels according to a main directory and several subject sub-directories for index search
The search keywords are as follows:
One type of keywords:
Nine categories of first-level keywords
Two types of keywords:
Second-level keywords + geographic region + language family
1. Telegraph #telegram#Promotion
#Group#channel#robot
#Search#index#navigation
2. Resources #Resources#Share
#Sharing#Welfare#moive#music#Books
3. Broadcasting #Broadcasting
#message#info#news#blog
4. Chat category #Chat
#chitchat#communication#city#area
#Chinese#English#language#country
#Mainland#HongKong#Taiwan
5. Computer category #Computer
#Hardware#software#VPN#programming
6. Life category #life
#Entertainment#Game#Funny#Anime
#Live#tourism
7. Subjects #Subjects
#Interest#hobbies#topic
8.Industry #Industry#business
9.To be classified
#notes Unclassified