Что делать если нужно поставить какую-то 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
Explore Contests with Trending Apps
#TON#BroBot
Trending Apps shares insights about engaging in TON activities using BroBot Contests. Users can enjoy straightforward access to reputable contests with a chance to win web3 prizes by visiting BroBot Contests through the Apps Center.
Source: link
@tonlines
🎁 New collection SBT contest from BroBot
Mini-collaboration Ton Events, Not a Trader и Шардинг, TON'ы, and the most attentive ones will notice an "easter egg".
Conditions for participation are simple as always:
🟨Go to the bot
🟨Connect your wallet
🟨Subscribe to the necessary channels and wait to claim SBT
💰 In addition, 150 random participants who scored 500 xp will receive $10 from $1500 prize pool. You need to complete it before August 13, 15:00 UTC.
#brobot#contest#tonevents
🎁The last day of the SBT collection contest from BroBot!
Mini collaboration Ton Events, Not a Trader and Sharding, TONs. And don't forget about the Easter egg.
The conditions for participation are, as usual, simple:
🟨Go to the bot
🟨 Connect your TON wallet
🟨 Subscribe to the desired channels and wait for the SBT stamp
💰 Additionally, 150 random participants who reach 500 xp will receive $10 from the $1500 prize pool.
Complete the tasks until August 13, 15:00 UTC. Today is the last day!🔥
#brobot#contest#tonsociety
🚀New contest — BroBot x xRocket
As usual — complete simple tasks and join trading tournament where for every $100 of volume in a WOOF/TON pair, you get 50 $XP and can win a prize.
Rewards: $7777
🚀Join Now to Get Your Prize
#BroBot#xRocket#DYOR#NFR
BroBot X Rubic
🔥 Our brothers announced a new 2-week contest, this time together with Rubik, DEX and bridge aggregator, in which you can get our favorite collectible SBT from TON Society and a share of $1500.
In addition, 150 random users who have earned 650 $XP earn $10 on their wallets for completing simple tasks!
➡️Join the contest
➡️Subscribe to the channels
➡️Claim SBT
🚀 The results of the competition: November 25, 15:00 UTC
#BroBot#TON#Rubic#SBT
🙏TON Society just added SBT Points
For now not all SBTs have amount of points that their owners will receive, but a trend is already visible — the more valuable in terms of the number of points are #DeFi SBTs and for contributors to the blockchain.
If you want to earn more points you have you should definitely get these SBTs:
💎 8 more days to get🙏9,500 for two valuable SBT Farmix in the BroBot contest✋
💎12 days to get tBook SBT Late Night DeFi with general speed 🙏27,000 points.
#TON#BroBot#SBT#Farmix
CapsGameon💎TON Community
The game was mentioned on the official TON channel, perhaps a hint that it is a future participant of the League.
CapsGame combines nostalgic gaming with innovative Web3 technologies, incentivizing active participation in the TON ecosystem through NFT trading. Players can earn rewards and profits from trading and upgrading their NFTs.
The game offers a PvP mode for those who like to take risks and bet their NFTs on the outcome of a battle with other players, as well as a safe PvE mode in which the player trains by playing with bots. CapsGame also encourages engagement and competition through rankings and quests.
And right now there is a new contest in BroBot together with #CapsGame in which you can get a unique SBT BroBot CapsGame and other prizes absolutely free.
☀️Complete tasks and get SBT!
#NFT#SBT#TON#BroBot
🎁Rewards from TON Events for BroBotContests!
Another contest from BroBot with the participation of partners has ended 💥 EVAA and Bemo! All prizes were sent to participants who completed the tasks!
Rewards of 1 $TON sent to:
UQDFzKFGNu9JjLQfAHNmcDg62NTFqq5moV5vLqdf3R8JVqGy
UQD5Jolha3j7_R8ugK8iHTkHDkn8-4AuaiWP0D_4Rw8Gopqu
UQA7G7ZqLvzP1R_q8TnWffyaTHKl8KGQ-v4zh9g6W3bsc3rF
UQA6lwBHvUMcD3n_D8QumuyzQQyZk_7bfYUJlMphVCJSW31K
UQDwC7A2FKAXSMPE8uRhMUmZ9sAe1laXEJwAS0xbkz60CLD5
UQDU6VTwZnCspEjQ9IPOsm5nO_GeACWFAOnvmjY44fx0aht8
UQCbm5QRULBCX5Ee9InkjTcjo9MSyvJasN-iK4mJz5vyP0U6
UQCJ2OZ6kNFXvPpb4wnXX8RU6KVv4R_F_10YAbgRC7-S9pVq
UQCgWfyxHL7p9nLuA4xfGEBNOr6nmE7q8RORvbs5IbHIZz2N
UQDfgzmjG2uFiU1BAFQyQ_mNtZLRVkkYhcGKFsFJRSWo5rYW
UQDQEi3YXHZ8fRs1RPHz5egKJRojKZzL93C6HBs-i-y8FEkc
UQDukQUY0vVhG0nTT9_n4tTB5nl0QBP07oS4dqjyoURFsJ8j
UQDr8VTd5Q54WXuGt6utwn6WoERJxSa3olGGqqnfsThDAZoP
#BroBot#EVAA#Bemo#TonEvents
🎁Giveaway from TON Events and BroBot. 3 days left!
The contest in BroBot is coming to an end with the participation of💥EVAA and Bemo with a huge prize fund and a small number of participants 🤫
How to get a prize from BroBot:
🟨Let's go to the bot
🟨 Connect your wallet (MyTonWallet or Tonkeeper)
🟨 Pass the daily captcha (at least 3 times)
🟨 Stake 1 TON on Bemo
🟨 We add 1 stTON to EVAA to the supply
How to receive a prize from us:
🟨 Share a story on your profile
🟨 Send to our chat a screenshot of completed task No. 4 from BroBot and your wallet.
🟨 Receive 1 $TON from us to your wallet after the end of the contest
3 days left!🔥
#BroBot#EVAA#Bemo#TonEvents
🎆New contest — BroBot x DeDust
Hey, bro! As usual — complete simple tasks: hold 1 $DUST, subscribe and boost the DeDust channel. Easy money, hurry up.
Prize pool: 50x20 $DUST, 2xSBT and BroBot XP points
❤️Complete the tasks
#BroBot#DeDust#DUST#DEX
–Hey Bro!
🕶
BroBot announced a new contest where users of well-known Telegram Mini App
💯RoOLZ Gods & Mortals can receive collectible SBTs from TON Society.
Additionally, 250 random participants who have earned 650 $XP will receive $10 in their wallets for completing simple tasks!
➡️Enter the Contest
➡️Complete the tasks
Prize pool: $2500, extra XP and unlimited SBT🤑
📆 Deadline:October 8, 15:00 UTC
#BroBot#Contest#TON#SBT#Roolz
😎–Hey Bro! $1,500 and free SBTs for you!
We’re launching a new quest with Farmix — leveraged lending liquidity protocol.
Prize pool: just gain 600 XP and hold Lending for a chance to win one of 150 $10 prizes, extra XP, and guaranteed #SBT from TON Society!
🚀Join the quest now and share with your Bros!
📖
Deadline: Dec. 27, 15.00 UTC
#TON#BroBot#contest#Farmix