Что делать если нужно поставить какую-то 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
The number of activated wallets in the TON network has reached 10 million!🚀
Just a year ago, the number of wallets that made at least one transaction was only 687 thousand versus 10 million now, that is, a 14-fold increase over the year!
Other interesting metrics on tonstat.com
➡ Transactions per day — 5.4M
➡ Network commission per day — 20k TON
➡ Burnt per day — 10k TON
➡ Mints per day — 50k TON
If you look closely at the last three metrics, the year when the community voted to burn 50% of commissions, these indicators differed hundreds of times but now have the same order of magnitude, which has a positive effect on the $TON rate.
We continue to monitor the development of The Open Network!❤️#massadoption#web3#crypto
⚡️Boost | 🎞YouTube |🌐Twitter
🚀Telegram is the driving force behind the mass adoption of cryptocurrencies
Since its launch, Telegram has become not just a messenger, but a key element in the world of cryptocurrencies. A recent article on Coindesk looks at exactly how Telegram is driving #massadoption of cryptocurrencies and why this has huge implications for the entire industry.🌐
Telegram, with its powerful ecosystem of channels, bots and groups, has become the ideal platform for communicating and spreading information about cryptocurrencies. Hundreds of thousands of users discuss new projects here every day, share knowledge and experience. Integration with cryptocurrency services and the creation of convenient tools for users make #Telegram not just a convenient messenger, but a real hub for crypto enthusiasts (check the Telegram App Center).
Particular attention in the article is paid to #TON (The Open Network) — Telegram’s own blockchain platform, which opens up new horizons for the integration of cryptocurrencies into everyday life. TON already offers users unique opportunities for transactions with digital assets, and its potential continues to grow.
Telegram is not just an intermediary, but an active participant in the process of accepting cryptocurrencies, offering convenient and accessible solutions for both beginners and experienced users.
This makes Telegram one of the most significant platforms for the development and popularization of cryptocurrencies around the world.
Original: Telegram Is Crypto's Adoption Machine
#Crypto#Telegram#TON
🚀 Exciting updates: UXLINK One account growth has exploded from 160K to 500,000+ in under 10 days! 💥
💰 Over 6,000,000 $UXLINK deposited as OAOG protocol’s universal gas
📈 Daily transactions: 10,000+ | Total transactions: ~1,000,000
This is what global community power looks like! 🌍✨ Thank you for trusting us to redefine #Web3.
Chain & account abstraction are revolutionizing user experiences—smoother, safer, and simpler for everyone.
As the world’s largest #Web3 social platform & infrastructure, we’re building the SOCIAL FOUNDATION for mass adoption.
💪The future is here—let’s shape it together! 🎉#UXLINK#MassAdoption#Web3Infrastructure#AccountAbstraction
Avalanche Visa Card Launches Today
Avalanche has officially launched its Visa card to promote cryptocurrency adoption. The card allows users to spend crypto easily in daily transactions, integrating DeFi solutions. This move aims to bridge the gap between traditional finance and the digital currency landscape, enhancing user accessibility to crypto assets. Read more here.
#Avalanche#Crypto#DeFi#Visa#Blockchain#Finance#MassAdoption#Payments#DigitalCurrency
📱Pay for Daily Expenses with Crypto — RedotPay &
💎TON!
#Massadoption just got another leg up thanks to RedotPay’s integration with the TON Blockchain. TON users can now spend $USDT-TON directly via the #RedotPay App or Card, compatible with Google Pay, Apple Pay, and Alipay, unlocking payments at over 🔗 130 million merchants worldwide, including #Starbucks and #Amazon.
🔥Exclusive Perks for TON Users: for a limited time, get discounts, cashback rewards and $5 bonus!
⬇️Download the RedotPay
💵 Get FREE $5 bonus on your wallet via promo code: j05mm
Why collect SBT and XP from🙏TON Society?
Let us remind you that SBT (Soulbound Token) is an NFT that is tied to your wallet, it cannot be traded or sold, which makes your wallet unique if it stores SBT NFT.
What is it for?
SBT NFT is a kind of “identity confirmation”, but only anonymous. SBT makes it clear to the sender that he is dealing with the right recipient and the right person behind him. Including when it comes to awards for contributions to the development of The Open Network. Such rewards can be obtained for activities within the Open League, they are displayed in your TON Society profile.
What will SBT and XP owners get?
Already, many people are collecting these achievements expecting to receive a reward in the future, but few people know how it works and what they can count on.
❤️Open League and SBT
• SBTs are issued (minted) by the TON Society for contributions to the development of the TON blockchain community - for example, for participating in competitions and attending AMA sessions, attending conferences and meetups.
• SBTs are issued by projects that receive incentives and grants through the Open League.
🫰Experience Points (XP) will become reputation points and will be converted into $TON
• XP points at a 1:1 ratio to $TON , can be exchanged for $TON at any time.
• Time-based formula affects the exchange rate - if $XP tokens are redeemed before March 31, 2025, the conversion will be at a less favorable rate.
• On March 31, 2025, 1 XP will be equal to 1 $TON
• SBT assumes a constant increase in XP income for inviting friends, purchasing Telegram Premium or TON DNS.
🔝TON Society will become the new public profile of the TON member, recognizing and rewarding everyone's achievements and contributions.
#TON#Toncoin#TheOpenLeague#MassAdoption#TONSociety#TONDNS#SBT#NFT
⚡️Boost | 🎞YouTube |🌐Twitter