Что делать если нужно поставить какую-то 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
#IDO Information
Start: 14:00 UTC, Jan 23, 2022
Fund Amount to be Raised: $150,000 on website and $150,000 on KingPad platform
- Currency: BUSD
- IDO/ Listing Price: $0.06/0.08
Join at: https://gleam.io/competitions/TwCMn-ido-whitelist-registration
Pool: 1
Guarantee Slot
- Min/Max: $50 - $500 BUSD
- For top 30 user with most entry.
Pool: 2 FCFS then public
- Open to whitelist address
- Allocation min: $50 max $500 per address
- Total winners: 570
The more entries you get by completing the tasks and referring people, the higher your chance of winning an allocation
Make sure you commit your BUSD as soon as possible as fundraising method is FCFS.
#DeFi
新的稳定币协议?Olympus与Nirvana对比
https://mirror.xyz/jojonas1.eth/mzwJKabgo19CDHHIPozzNWc0Wi5anfQkBAWi40-zqXQ
#IDO(新的标签,会收集当前正在进行的一些IDO项目,没有投资建议)
Step App is creating a gamified metaverse for the fitness economy. Walk, jog, and run to socialize, play, and earn.
https://daomaker.com/company/step-app#overview
🎙IDO ANNOUNCEMENT 🔥
We're thrilled to announce our partnership with Enjinstarter - the third launchpad that will be hosting our IDO on the 20th of February.
Enjinstarter is one of the leading ecosystems for creators & game development studios in the blockchain space. Together, we will be onboarding new users into the blockchain space.
All you should know:
🗓IDO | 20th February
⏰Apply for Whitelist starts on 13th February!
🔍How to participate in Enjinstarters IDO: https://medium.com/enjinstarter/how-to-participate-in-an-ido-on-enjinstarter-925ca0d5fa4a
✅ Official Links:
- Website
- Launchpad
- Twitter
#IDO#Promotion
⚡️🚫Storm x Notcoin: your pass to STORM IDO
🚀 Friends, we know how much you are waiting for the #IDO token $STORM , and today you can take the next step towards launch!
⭐️ Meet The Gateway to the STORM IDO campaign on Tonstarter — the largest TON launchpad where the future #IDO will take place.
🏆 By completing simple tasks in the bot, you get a chance to win a whitelist for purchasing a #STORM token, and your activity in Notcoin and the TON ecosystem will help increase your chances of receiving an allocation.
👉Complete tasks via the link and receive an exclusive allocation for the purchase of the STORM token
#STORM is coming!⚡️
BIG NEWS 🔥We know many of you have been waiting for this for so long. Let us give a brief of everything you should know about the upcoming $CETUS #IDO and #Whitelist policies through this blog. Don't miss it! 🐳
Details: https://medium.com/@CetusProtocol/the-cetus-ido-is-coming-f7dedf4031a3
https://twitter.com/CetusProtocol/status/1653581232750620672?s=20
@everyone
🔥 As the leading launchpad on the TON blockchain, #TonUP is pleased to disclose changes to the revenue distribution model for the platform's revenue.
Going forward, all the platform revenue generated from IDO service fees will be allocated as follows:
⚫️ 25% will be used to provide #IDO tokens to the Launchpool program for the benefit of $UP token holders.
⚫️ 50% will be earmarked for $UP token buyback and burns, reducing the overall circulating supply of $UP.
⚫️ 25% directed towards supporting the #TonUP team
It's important to note that future IDO participants will no longer receive $UP tokens as a reward.
🔗 To maintain transparency, TonUP will regularly update the community on buyback and burn details on this page.
🔥 All transactions from the tonup-buyback.ton wallet will also be publicly disclosed.
❤️ This new model is designed to better align incentives and provide greater value to our holders. The TonUP team looks forward to sharing more updates soon.
🚨 IDO Whitelist Still OPEN! 🚨
Don’t miss your chance to join the $SING IDO! 🪙 Secure your spot and get ready for the rewards!
⏰ Act fast! Register here 👉https://app.galxe.com/quest/Kommunitas/GCyBKtVSPM
IDO Details: https://launchpad.kommunitas.net/pool/SING/PublicCross
#SingSing#IDO#Whitelist
🎤Announcement | Chat | X (Twitter) | Website | Game
🚀 The $BYIN IDO is now confirmed for August 26th on #TonUP!
🎮@BYINchann is a gateway to effortlessly creating and trading memecoins on #TON. It offers features like easy token creation, on-platform fundraising, dynamic pricing, and seamless #DEX integration. The platform also provides Telegram-based tools like reminders, trending alerts, and management bots.
The $BYIN IDO will be offering three rounds this time:
1️⃣August 26th UTC 10:00 AM - 11:00 AM, KOL & Community Round: This exclusive round is reserved for active community members and key opinion leaders. Stay tuned to the social channels for details.
2️⃣August 26th UTC 11:00 AM - 13:00 PM, UPer Round: This round is open only to $UP token holders. To participate, simply hold and stake your $UP to earn token rewards and potential allocation. Staking details will be announced soon.
3️⃣August 26th UTC 13:00 PM - August 27th UTC 13:00 PM, Public Round: This round is open to all users with limited allocation. The $BYIN #IDO price details and participation amounts will be gradually revealed.
🫥For more IDO details, please visit: tonup.io/project/BYIN
🫥 For more project info, please check: community.tonup.io/t/all-you-need-to-know-about-byin-ido
💎 The BYIN IDO is committed as part of the #TonUP CPP program, offering a comprehensive refund policy if the $BYIN token price dips below the IDO price. So don't miss out on this chance with a full promise of protection!
We will give 1 WL's to KOL & Community Round to the one who left more 🌟 Stars under this post
TonUP | Chat | Blog | X | Website
💥Metastrikers💥
🎥 Video information
It's the moment you have all been waiting for👀
Can you feel the meta shifting 🤯
🧨 Click links to find out details about our #IDOon@SeedifyFund, @RoseonFinance and @paid_network
🔊🆙
ITS WILL BE HUGE💣💣💣
#Metaverse#PlayToEarn
🚀 Only one week left until our IDO launches!
The excitement is building up as we get closer to the big day. Get ready to join us on this incredible journey!
#IDO#Countdown#SingSing🎉
🎤Announcement | Chat | X (Twitter) | Website | Game
📢 Big Announcement!
The Whitelist for SingSing's IDO opens on 4AM UTC - Nov 1.
Mark your calendars and get ready to secure your spot! 🚀
Don't miss this chance to be part of something amazing.
#SingSing#IDO#Crypto#Blockchain#Whitelist
🎤Announcement | Chat | X (Twitter) | Website | Game