Что делать если нужно поставить какую-то 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
We have completed the first series of posts, where we showed the interface of the future BLC Market application.
What's next.
The project is now moving into the next phase:
• interface testing within the Pioneers group
• feedback collection
• preparation of the backend part of the application
• development of the referral system and game mechanics
Also in development is the first game mechanic of the application - the tap module.
It will become part of the BLC economic system.
The next updates will be dedicated to:
• application testing
• referral mechanics
• early participant system
The development of the project continues.
#BLC#freelance
FAQ | BUY
Today at 21:30 CET
Summing up BulCoin
• announce 20 winners
• show the design of BLC Market v2
• talk about the next stage of the project
During the AMA session, one of the random viewers will receive 1,000,000 BLC
#AMA#giveaway#BLC
FAQ | BUY
We continue to show what the BLC Market will look like.
Currently, the basic logic of interaction within the app is under development:
— user profile
— task structure
— navigation within the interface
This is the first layer on which the entire system will be built.
Next, we will show how exactly users will interact with each other.
#freelance#community#BulCoin#BLC#TON
FAQ | BUY
How interaction will work in BLC Market
The main idea is to eliminate unnecessary intermediaries.
User:
- creates a task
- receives responses
- chooses a contractor
Everything happens within one interface.
We make the mechanics as simple as possible to lower the entry barrier.
#freelance#tasks#BulCoin#BLC#TON
FAQ | BUY
Why do we emphasize on interface?
Most Web3 products are complex.
We are going in a different direction:
— simple structure
— clear actions
— minimum of unnecessary steps
Convenience first, then everything else.
This is critical for mass use.
#freelance#interface#BulCoin#BLC#TON
FAQ | BUY
Our recommendation
How to earn on pool-liquidity if you only have BulCoin?
1. Go to App.Tonco.io in the pools section and enter BLC in the search.
2. Click on Create position
3. Enter the minimum price above the market, and the maximum no less than $0.11. This will be the minimum price at the start of privatization in Chuvashia for BulCoin
4. Enter the amount and create
5. Now investors will buy BLC from you, and you will get the maximum profit from trading!
#pool#tonco#liquidity#BLC
FAQ | BUY
The composition of the Council of large Bulcoin holders consisting of top 10
1. Olesya Zhukovets 460m
2. Mischshi Oreshnikov 362m
3. Er Chon 260m
4. Irӗklӗx 200m
5. Suldin Nikita 197m
6. Oleksandr Yasenchuk 100m
7. Alexander Samokaev 72m
8. Alexander Zolotarev 51m
9. Vlasov Dmitry 45m
10. Oleg Yelkin 45m
If you own more than 45m Bulcoin, you can write in our bot and get a place in the council of large holders
#SKD#blc#Guide#dao
During the stream with the network state VERV, a pool-liquidity was announced between VRV and BLC
You can trade this pair on DeDust
What other pairs are available for BulCoin?
BLC/USDT
BLC/TON
BLC/44AD
#VERV#BulCoin#BLC#VRV#Pool
FAQ | BUY
🚀 We are proud to present the first Chuvashia-Volga Bulgaria national cryptocurrency - BulCoin (BLC) 🌟
It is designed to support Chuvash culture, heritage, and economic growth 🌿
Join us on this exciting journey to the digital future! 💪
#BulCoin#BLC#Chuvashia#VolgaBulgaria#CryptoCommunity#DigitalEconomy
@bulcoin_blc