Что делать если нужно поставить какую-то 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
🔥 Create your FIRST AA Smart Wallet on TokenPocket! #AccountAbstraction
✅ No seed phrase worries.
✅ Without Gas concerns.
✅ Easy-to-Use.
✅ Seamless decentralized experience.
Tutorial
👉https://tokenpocket-gm.medium.com/create-the-aa-wallet-on-tokenpocket-8132b4ed5d87
Download Your TokenPocket
👉https://www.tokenpocket.pro/
【Details】https://twitter.com/TokenPocket_TP/status/1722515584640856575
【Powered By】Crypto Box
📣Create the AA Wallet on TokenPocket_TP!
🫡 Ready for the next billion users to join Web3!
#AccountAbstraction is one of the best solutions to address the limitations of current EOA wallets, while also bringing more flexibility and operability to the Web3 wallets.
📱TokenPocket Android version now has launched AA Wallet, bringing more Web 3.0 possibilities to crypto users.
Here is the tutorial to guide you on how to start your AA journey on #TokenPocket!👇
https://medium.com/@tokenpocket-gm/create-the-aa-wallet-on-tokenpocket-8132b4ed5d87
🔥Ready your TokenPocket AA Wallet!
🚀Ready for the upcoming surprise for TP users!
【Details】https://twitter.com/TokenPocket_TP/status/1721907394614321592
【Powered By】Crypto Box
📣Create the AA Wallet on TokenPocket_TP!
🫡 Ready for the next billion users to join Web3!
#AccountAbstraction is one of the best solutions to address the limitations of current EOA wallets, while also bringing more flexibility and operability to the Web3 wallets.
📱TokenPocket Android version now has launched AA Wallet, bringing more Web 3.0 possibilities to crypto users.
Here is the tutorial to guide you on how to start your AA journey on #TokenPocket!👇
https://medium.com/@tokenpocket-gm/create-the-aa-wallet-on-tokenpocket-8132b4ed5d87
🔥Ready your TokenPocket AA Wallet!
🚀Ready for the upcoming surprise for TP users!
【Details】https://twitter.com/TokenPocket_TP/status/1721907267526877416
【Powered By】Crypto Box
🚀Bringing the next billion users into Web3! TokenPocket_TP
Account Abstraction has offered us a new path for advancement.
❓What is Account Abstraction?
❓How can it transform our Web3 experience?
Here's the ultimate beginner's guide to help you grasp and explore Account Abstraction to the fullest.👇👇
#AccountAbstraction#TokenPocket
https://tokenpocket-gm.medium.com/account-abstraction-e9cc59a7d6a3
【Details】https://twitter.com/TokenPocket_TP/status/1715310984003555418
【Powered By】Crypto Box
🚀 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
🆕We just released TokenPocket’s New Version on Android. 🔺1.8.9🔺
🔵 Support AA Wallet. #AccountAbstraction
🔵 Support #Nostr Protocol on #Bitcoin Network and dogecoin Network.
🔵 Support Unisat’s new signature protocol.
🔵 Modify the signature verification for SuiNetwork.
🔵 Support Malaysian, Danish, and Hungarian.
👉http://tokenpocket.pro
#AAWallet#AccountAbstraction#TokenPocket
【Details】https://twitter.com/TokenPocket_TP/status/1721862534695936492
【Powered By】Crypto Box
🆕We just released TokenPocket’s New Version on Android. 🔺1.9.3🔺
1. The Market page supports #MEV Protection.
2. The Market page supports lifiprotocol
3. KeyPalWallet Hardware Wallet supports trondao Sign Message V2.
4. The Transfer page supports domain resolution for associated wallet addresses, including the #BTC Domain, #BTC Inscription Domain, #Eths Inscription Domain, and dotbitHQ domain.
5. Support #Permit transaction resolution.
6. Optimize signature management for trondao MultiSig wallets.
7. Optimize the user experience of AA wallets. #AccountAbstraction
👉http://tokenpocket.pro
【Details】https://twitter.com/TokenPocket_TP/status/1730851266912563295
【Powered By】Crypto Box
🚀 Ethereum's Upcoming Glamsterdam Upgrade Progresses Amid Development Challenges
Ethereum Foundation has released its latest development update, indicating steady progress in the upcoming Glamsterdam upgrade. According to Foresight News, while the implementation of ePBS (protocol-level PBS) is complex, the related development network is stabilizing, and the block-level access lists (BALs) development network is advancing smoothly. The current goal is to launch the first generalized Glamsterdam development network next week if the ePBS development network remains stable, followed by client releases, security audits, and test network testing. Additionally, EIP-7954, aimed at increasing the maximum contract size, is likely to be prioritized.
The subsequent Hegotá upgrade has selected FOCIL (EIP-7805) as the core feature for the consensus layer, while the proposal for account abstraction (AA), EIP-8141, remains in a pending introduction (CFI) status due to lack of consensus. Non-core feature proposals for Hegotá were initiated on April 9. Regarding the network gas limit, the current benchmark target is set at 60 million, with higher limit testing ongoing. As for the upgrade timeline, Glamsterdam is unlikely to go live in the second quarter, and the progress of Hegotá will largely depend on the completion of the former.
#Ethereum#Glamsterdam#ePBS#BALs#EIP7954#Hegotá#FOCIL#EIP7805#AccountAbstraction#EIP8141#Blockchain#Crypto#Upgrade#Development#ETH