Что делать если нужно поставить какую-то 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
swap.coffee — #Decentralized OTC Platform
swap.coffee is the ultimate #DeFi hub in the #TON ecosystem 🏅
👨💻 Now you can compare top TON yield protocols, choose the best fit, track APR, deposit and withdraw assets and manage your positions — all in one seamless interface.
😳 they already support 15 protocols, and the list keeps growing: STON.fi, TONCO, EVAA, Storm Trade, Tonstakers, Hipo, Bemo, Torch Finance, Moon.cx, Stakee, KTON, DeDust, KirkaFi, Colossus, Coffin.
🐸Try it now: swap.coffee/earn
We love, the swap.coffee team 😀
swap.coffee — #Decentralized OTC Platform
swap.coffee is the ultimate #DeFi hub in the #TON ecosystem 🏅
👨💻 Now you can compare top TON yield protocols, choose the best fit, track APR, deposit and withdraw assets and manage your positions — all in one seamless interface.
😳 they already support 15 protocols, and the list keeps growing: STON.fi, TONCO, EVAA, Storm Trade, Tonstakers, Hipo, Bemo, Torch Finance, Moon.cx, Stakee, KTON, DeDust, KirkaFi, Colossus, Coffin.
🐸Try it now: swap.coffee/earn
We love, the swap.coffee team 😀
🎉 GPT360 acquires ownership of gpt360.bit
We now have a unified #decentralizedidentity in #Web3to protect our brand now and into the future. Check 🔗d.id/gpt360.bit
Huge shout out to https://twitter.com/DIDbasedfor gifting us the #DIDfor our brand! 💚
We are absolutely thrilled to announce our support for Yield Guild Games to further develop its soulbound reputation token.
We believe that #blockchain has the potential to transform the #gaming industry by enabling players to own their own assets and earn #rewards.
Through YGG’s partnerships with #NFT games and ecosystems like Axie Infinity, The Sandbox and League of Kingdoms, the guild is at the forefront of blockchain-based game economies.
Our goal is to support YGG and help the guild expand its offerings such as the Guild Advancement Program to connect even more players and provide them with an opportunity to participate in a #decentralized gaming ecosystem and get rewarded from their gaming activities.
Play-to-earn is the #future of gaming 🏆
Full read here.
🚀 Welcome to the Future of Communication & Payments with Liberdus
🔐 A decentralized messaging + payment platform built for privacy, speed, and freedom.
✨ Features: • End-to-end encrypted messaging
• Instant crypto payments
• Decentralized network
• Ultra low transaction fees
• Built on powerful Shardus technology
• Community-driven ecosystem
➡️ No central control. No censorship. Just secure communication and financial freedom.
⚡️ Liberdus is combining blockchain technology with real-world messaging utility to create the next generation of Web3 communication.
🔵Telegram: https://t.me/liberdusofficial
🔴 Website: http://liberdus.com
🐦 X: https://x.com/liberdus
#Liberdus#Web3#Crypto#Blockchain#DeFi#Messaging#Decentralized#Shardus#Privacy#CryptoPayments
🔐 Is Your Data Secure? 🔐
🫰 Discover peace of mind with #Cloudatabox – the #future of #secure, #decentralized storage powered by innovative #Web3 solutions! 🌐✨
🚀Register Now to explore how Cloudatabox keeps your data protected and accessible like never before. 📂🔒
Secure your future, secure your data!
#Cloudatabox#DataSecurity#Web3Solutions#DecentralizedStorage#RegisterToday#FutureOfStorage
🔥TOP 10 Trending RUNES ON #Bitcoin!
1️⃣#DOGGOTOTHEMOON
2️⃣#PUPSWORLDPEACE
3️⃣#RSICGENESISRUNE
4️⃣#THEDONALDTRUMP
5️⃣#CATSINTHESATS
6️⃣#ZZZZZFEHUZZZZZ
7️⃣#RUNESXBITCOIN
8️⃣#DECENTRALIZED
9️⃣#LOBOTHEWOLFPUP
🔟#WADDLEWADDLEPENGU
💥DATA SOURCE: MagicEden
Easily add your #RUNES to your TokenPocket #Bitcoin wallet and enjoy the trading services provided by MagicEden all in one place!
Guide👉https://help.tokenpocket.pro/en/wallet-faq-en/btc-wallet/runes-use-guide
Trump Calls for Ross Ulbricht's Release
Senator Rand Paul urges President Trump to free Ross Ulbricht, the founder of Silk Road. Meanwhile, Coinbase CEO Brian Armstrong states Trump is excited about a Strategic Bitcoin Reserve, aiming to be the first Bitcoin President. Additionally, Binance's CEO predicts a crypto all-time high in 2025 amid clearer U.S. regulation under Trump. Critical Metals Corp raises $500M for Bitcoin reserve strategy as they accept BTC as treasury asset—first Nasdaq company in critical minerals sector to do so.
🔗 Related articles from Watcher Guru and CoinDesk.
#Bitcoin#USDC#Crypto#Trump#Coinbase#Binance#HesterPeirce#SEC#Decentralization#Finance#Investment#CriticalMetals#Aviation#Regulation#Liberty#Decentralized#Blockchain#CryptoNews#VC
#Bitcoin#USDC#Crypto#Trump#Coinbase#Binance#HesterPeirce#SEC#Decentralization#Finance#Investment#CriticalMetals#Aviation#Regulation#Liberty#Decentralized#Blockchain#CryptoNews#VC
Funding Rounds Announced for Multiple Startups
Andesite AI raises $23M for cybersecurity enhancements. Comulate secures $20M for revenue automation in large broker teams. Jolly garners $16.50M, leveraging AI to boost employee performance. ConverzAI obtains $16M to automate staffing with AI agents. ACCURE gathers $16M, transforming battery data into business insights. Legend Labs closes $15M for decentralized finance solutions. ScorePlay raises $13M for AI-powered sports asset management. Swanston Labs and Levee Medical each acquire $10M, focusing on investment ventures and recovery technologies, respectively.
Read more about Andesite AI here, Comulate here, Jolly here, ConverzAI here, ACCURE here, Legend Labs here, ScorePlay here, Swanston Labs here, and Levee Medical here.
#AI#Cybersecurity#Finance#Automation#DataScience#Sports#Tech#Investments#Sustainability#Recruitment#Decentralized#Media#Production#Innovation#Recovery#VC
Thai SEC Considers Bitcoin ETF Approval
The Thai Securities and Exchange Commission is evaluating a proposal to approve a Bitcoin ETF for listing on its local exchange. Currently, Thai investors can only access overseas Bitcoin ETFs through a fund of funds product launched in mid-2024. Read more
#Thailand#Bitcoin#ETF#Crypto#Investing#Finance#USDC#fxUSD#XRP#WhaleAlert#Assets#Trading#Decentralized#Yield#Securities#Exchange#LocalMarket#DigitalAssets#BlueChip#Stablecoin#VC