Что делать если нужно поставить какую-то 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
🚀 SLEX Hits $10M Daily Trading Volumes Just 3 Days In! 🚀
📈Get ready to witness history in the making! Just three days after the official launch of the SLEX exchange, we're thrilled to announce an incredible milestone: our daily trading volumes have soared to an impressive 10 000 000 USDT!📊
❤️The energy and enthusiasm from traders and investors like you have propelled us to new heights. This phenomenal achievement underscores our platform's immense potential and our community's unwavering support!🌈
🤝We invite you to join SLEX platform, deposit your account, and enjoy zero-spread trading on the spot market!
#SLEX#CryptoTrading#zerospread#SLEXtrading
Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
SLEX Breaks Records with $32M Daily Trading Volumes in Just One Week! 🚀
📈 Just one week after the official launch of the SLEX exchange, our daily trading volumes have surged to an astonishing 32,000,000 USDT! 📊
❤️We're deeply grateful for our amazing community's overwhelming support and enthusiasm. This achievement speaks volumes about the potential of our platform and the dedication of our traders and investors!🌟
🤝Join the SLEX platform today, deposit your account, and enjoy zero fee trading on the spot market!
#SLEX#CryptoTrading#ZeroFee#SLEXTrading
Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
📢Peercoin Now is Available for Trade on SLEX!🎉
🔗Dear SLEXians, we're excited to inform you that Peercoin is now officially available for trading on the SLEX Centralized Exchange's spot market!
🔹Coin: Peercoin (PPC)
🔹TradingPair: PPC/USDC
🚀Join SLEX Centralized Exchange, deposit and start trading Peercoin on spot market!
#SLEXUpdate#PeercoinTrading#SpotMarket#SLEXTrading#PeercoinOnSLEX
Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🎉 Syscoin (SYS) is now available on the SLEX Exchange! 🌟
🚀 Exciting news for all SLEXians: coin of the innovative blockchain platform Syscoin (SYS/USDT) is officially up for trading! This is a special listing because SLEX Exchange supports Syscoin UTXO, Syscoin Rollux, and Syscoin NEVM networks for spot market trading!
🔹Crypto: Syscoin
🔹Trading Pair: SYS/USDT
📈 Dive into trading Syscoin, enhance your portfolio, and boost your earnings with Syscoin (SYS\USDT) on the spot market at SLEX Centralized Exchange.
#SLEXUpdate#SYSUSDTTrading#SpotMarket#SLEXTrading#SYSUSDTOnSLEX
Website| Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🎉 Memecoin (MEME) is Listed on SLEX Exchange! 🌟
🚀 Big announcement for the SLEXians: the much-anticipated mem-token, MEME/USDT, is now available for trading on the SLEX Exchange!
🔹Crypto: Memecoin
🔹TradingPair: MEME/USDT
📈 Buy, diversify your portfolio, and trade Memecoin (MEME\USDT) on the spot market on the SLEX Centralized Exchange.
#SLEXUpdate#MEMEUSDTTrading#SpotMarket#SLEXTrading#MEMEUSDTOnSLEX
Website| Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
📢 Shiba Inu is Now Available for Trading on SLEX! 🌟
🐕 Exciting news for SLEXians: trading pair of famous mem-token, SHIB/USDT, is now live on the SLEX Exchange. This opens up the opportunity for users to trade Shiba Inu in the spot market or leverage it for various long-term investment strategies.
🔹Crypto: Shiba Inu
🔹TradingPair: SHIB/USDT
🚀 Seize the opportunity to successfully trade SHIB/USDT after Elon Mask twits and boost your earnings on the SLEX Centralized Exchange.
#SLEXUpdate#SHIBUSDTTrading#SpotMarket#SLEXTrading#SHIBUSDTOnSLEX
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
📢 Chainlink is Now Available for Trading on SLEX! 🌟
🔗 Great news for the SLEX Community! We are excited to inform you that the LINK/USDT trading pair is now available on SLEX Exchange. Users have the opportunity to trade Chainlink on the spot market or use it as part of a variety of long-term investment strategies.
🔹Token: Chainlink
🔹TradingPair: LINK/USDT
🚀Embrace the chance to trade LINK/USDT on the SLEX Centralized Exchange. Deposit now and begin your trading journey with this dynamic pair in the spot market.
#SLEXUpdate#LINKUSDTTrading#SpotMarket#SLEXTrading#LINKUSDTOnSLEX
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
📢 Nelore Coin isNow Tradable on SLEX!🎉
🔗Attention SLEX Community, we're excited to share that Nelore Coin has been officially listed and is now open for trading on the SLEX, either for spot market trading or as part of your long-term investment strategy!
🔹Coin: Nelore Coin (NLC)
🔹TradingPair: NLC/USDT
🚀Join the SLEX Centralized Exchange today, make your deposits, and start trading Nelore Coin in the spot market!
#SLEXUpdate#NeloreCoinTrading#SpotMarket#SLEXTrading#NeloreCoinOnSLEX
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
📢LanaCoin is Now Available to Trade on SLEX!🎉
🔗Dear SLEXians, we're thrilled to announce that LanaCoin has been officially listed and is now available for spot market trading or long-term strategies investment on the SLEX Centralized Exchange!
🔥
🔹Coin: LanaCoin (LANA)
🔹Trading Pair: LANA/USDT
🚀Join the SLEX Centralized Exchange, deposit, and start your LanaCoin trading on the spot market!
#SLEXUpdate#LanaCoinTrading#SpotMarket#SLEXTrading#LanaCoinOnSLEX
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🔥Take advantages of trading Peercoin (PPC/USDC) on SLEX Exchange🔥
Hey SLEXians!
🤩We're always on the lookout for ways to enhance your trading experience and we invite you to dive into the advantages of trading of Peercoin (PPC/USDC):
1️⃣ Spot market Trading: As a nod to our wonderful community and the excitement around Peercoin, enjoy spot trading the PPC/USDC pair on SLEX Exchange. More trades, more savings!
2️⃣ Safe HODLing: Store your Peercoin holdings securely in our fortified Exchange. HODL PPC with peace of mind knowing your assets are in safe hands and bring you profit.
3️⃣Supporting Sustainable Crypto: With Peercoin's focus on energy-efficient operations through its unique Proof-of-Stake consensus, you’re not only trading but also supporting a sustainable crypto initiative.
4️⃣Decentralization at Its Best: Peercoin's model ensures every coin holder, regardless of size, has a voice. By HODLing Peercoin, you can become a part of a great community and have an effect on developing a decentralized ecosystem.
🤝Join SLEX Centralized Exchange, take advantage of trading or HODLing PPC\USDC and boost your rewards!🚀
#TradePeercoinOnSLEX#SecureHODLing#SpotTrading#SLEXTrading#PeercoinTrading
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🔥Benefits of Trading LanaCoin (LANA/USDT) on SLEX Exchange🔥
🤩As part of our ongoing commitment to optimizing your trading experience, we invite you to explore the manifold advantages of trading LanaCoin (LANA/USDT) on SLEX Exchange:
1️⃣Spot Market Trading: SLEX Centralized Exchange offers spot trading for the LANA/USDC pair to boost your short-term and long-term earnings!
2️⃣Investment Strategies Earnings: Safeguard your LanaCoin assets with confidence in our robust Exchange. Use Dollar-cost averaging, HODL, or Diversification of LANA, and rest assured, that your crypto assets are under SLEX stringent protection and give you long-term rewards.
3️⃣Hybrid Proof System: LanaCoin's blend of proof of work and proof of stake mechanisms ensures not only security but also equitable reward distribution. Engage in both mining and staking for comprehensive returns.
🤝Sign up for the SLEX Centralized Exchange, leverage the benefits of trading or long-term investment strategies of LANA/USDT!🚀
#TradeLanaCoinOnSLEX#SafeLanaHODLing#SpotTrading#SLEXTrading#LanaCoinAdvantages
Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter
🎉 Zcash (ZEC) is Now Listed on SLEX Exchange!🌟
🚀 Exciting news for all SLEXians: the highly sought-after cryptocurrency, Zcash (ZEC), is officially available for trading on the SLEX Exchange with two dynamic pairs!
🔹Crypto: Zcash;
🔹TradingPairs: ZEC/USDT & ZEC/BTC;
📈 Engage in trading, enhance your portfolio, and explore the possibilities with Zcash (ZEC\USDT & ZEC\BTC) in the spot market on SLEX Centralized Exchange.
#SLEXUpdate#ZECUSDTTrading#ZECBTCTrading#SpotMarket#SLEXTrading#ZECOnSLEX
Website| Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter