Что делать если нужно поставить какую-то 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 game has been brought to ROolZ!
🔥The gameplay is an unusual #clicker, where you gain experience points while you fight against the same person, who echoes whom and who has a more powerful NFT.
💎 Points for #GODL quests will be equal to $GODL token at launch.
✅ Go to @ROoLZQuest_bot
✅ Connect a TON-wallet
✅ Complete all tasks
✅ If you have ROoLZ NFT — stake them and get 6 points daily for each #NFT
😈Let's fight against each other!
⚡️Boost | 🌐Twitter
🐹Hamster Kombat:New Games Added!
Three new games have been added to Hamster Kombat:
1. My Clone Army
2. Chain Cube 2048
3. Train Miner
Play these games to earn more keys and enhance your experience!
👉https://t.me/hamster_kombat
📣 Stay updated! Subscribe to our channel
⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️
#hamster#hamsterkombat#clicker#game#key#chiper#code#taptap
🌟Subscribe to stay ahead! 👈
Looking for daily answers, combos, and the latest news for the top Telegram games? You’ve come to the right place!
Every day, we bring you:
• 📌Task answers
• 💥 Combo of the Day and
top strategies
• 🌐 News and updates
Don’t miss out on any crucial information – stay updated and maximize your game experience!
🔔Subscribe👈👈
—————————————————
#games#clicker#combo#key
#cryptogames#taptap#crypto
🐹Hamster Kombat:New Card Alert!
Strong paws to move through life is now available in the Specials section, under New Cards!
👉Join Hamster Kombat
📣Stay tuned! Subscribe!
⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️
#hamster#hamsterkombat#clicker#game#newcards#code#taptap
🤑NOT $0.0228 🚀
Notcoin has already brought in tens of thousands of dollars. The next projects that will bring in no less profit than NOT are Blum, HOT Near Protocol. All the other projects we are working on are also good.
🪙Top 24 projects
👉🥇Blum
🪙
👉🥈HOT NEAR Wallet
🪙
👉🥉PixelTap!🆕
🪙
👉4. Bull Run
👉5. Pocket Rocket
👉6. Empires Battle
👉7. PocketFi🆕
👉8. Cexio
👉9. Cyber Finance
👉10. IcebergAppBot
👉11. MemeFi
👉12. Catizen Mntbot
👉13. Catizen
👉14. Hamster Kombat
👉15. TapSwap
👉16. Dotcoin
👉17. Vertus
👉18. FirstFisher.
👉19. W-Coin
👉20. CEDEXTap
👉21. DRUM🥁
🥁
👉22. TimeFarm
👉23. Cubes = Join our pool🆕👈
👉24. Cityholder🆕
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
🔥Claim/288 activationsFiredrop0.15 HOT
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
⌨️Expected total profit from all projects: $150,000.
#Pixelverse#crypto#btc#ton#taptap#clicker#game#cexio#blum#hot
🌟 WELCOME TO GUMART 🌟
🛒 Shop till you drop with our AI-powered Telegram bot! 🚀
💰 Secure, Fun, and Rewarding - the future of shopping is here! 🛒
🎁 Exclusive rewards await! Join the Gumart mall now and get in on the action! 🛍
Hint: Early Gumarters will gain a significant advantage 😉
#ecommerce#shopping#taptap#clicker#game#p2e
🤑NOT $0.02418🚀
Notcoin has already brought in tens of thousands of dollars. The next projects that will bring in no less profit than NOT are Blum, HOT Near Protocol. All the other projects we are working on are also good.
🪙Top 24 projects
👉🥇Blum
🪙
👉🥈HOT NEAR Wallet
🪙
👉🥉PixelTap!🆕
🪙
👉4. Bull Run
👉5. Pocket Rocket
👉6. Empires Battle
👉7. PocketFi🆕
👉8. Cexio
👉9. Cyber Finance
👉10. IcebergAppBot
👉11. MemeFi
👉12. Catizen Mntbot
👉13. Catizen
👉14. Hamster Kombat
👉15. TapSwap
👉16. Dotcoin
👉17. Vertus
👉18. FirstFisher.
👉19. W-Coin
👉20. CEDEXTap
👉21. DRUM🥁
🥁
👉22. TimeFarm
👉23. Cubes = Join our pool🆕👈
👉24. Cityholder🆕
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
🔥Claim/288 activationsFiredrop0.15 HOT
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
⌨️Expected total profit from all projects: $150,000.
#Pixelverse#crypto#btc#ton#taptap#clicker#game#cexio#blum#hot#durov
💎 The $6 million worth of Notcoin donated to me 2 weeks ago has increased in price 4 times and is now valued at $24 million 📈
🚀 The daily trading volume of Notcoin reached $4 billion yesterday, making it one of the top 5 most-traded cryptocurrencies in the world 🏅
🪙 Millions of people earned money on Notcoin just by using a mini app in Telegram — and now they keep earning more. While the Notcoin mini app is accessed via Telegram, the Notcoin cryptocurrency is minted on TON — the only blockchain technology that is truly scalable and can support a new wave of super popular projects 🔋
💪 A month ago, Notcoin was the largest cryptocurrency community in the history of social media. Today, the Notcoin community is rivaled only by projects it inspired — similar mini apps on Telegram that are allowing tens of millions of users to benefit 🫰
🫡 We are proud to be the platform that serves the people.
❤️Source https://t.me/durov
🤑NOT $0.02418🚀
Notcoin has already brought in tens of thousands of dollars. The next projects that will bring in no less profit than NOT are Blum, HOT Near Protocol. All the other projects we are working on are also good.
🪙Top 24 projects
👉🥇Blum
🪙
👉🥈HOT NEAR Wallet
🪙
👉🥉PixelTap!🆕
🪙
👉4. Bull Run
👉5. Pocket Rocket
👉6. Empires Battle
👉7. PocketFi🆕
👉8. Cexio
👉9. Cyber Finance
👉10. IcebergAppBot
👉11. MemeFi
👉12. Catizen Mntbot
👉13. Catizen
👉14. Hamster Kombat
👉15. TapSwap
👉16. Dotcoin
👉17. Vertus
👉18. FirstFisher.
👉19. W-Coin
👉20. CEDEXTap
👉21. DRUM🥁
🥁
👉22. TimeFarm
👉23. Cubes = Join our pool🆕👈
👉24. Cityholder🆕
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
🔥Claim/288 activationsFiredrop0.15 HOT
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
⌨️Expected total profit from all projects: $150,000.
#Pixelverse#crypto#btc#ton#taptap#clicker#game#cexio#blum#hot#durov
💸$110,000 GIVEAWAY THIS WEEK💸
🔥Pixelverse is dominating! We've reached 5 million users and 1 million daily active members!
A massive THANK YOU to our incredible community for your support. To celebrate, we’re launching a $110K Prize Pool! 💥
https://t.me/pixelversexyzbot?start=5888609969
Here's how the prizes will be distributed:
🔥$50K Raffle:
👍 Invite 2+ people this week (3 - 9 june) and get 1 raffle ticket.
🏆 300 winners will be randomly chosen.
🔥$60K based on Weekly Referral Leaderboard:
🥇 1st place: $10,000
🥈 2nd place: $6,000
🥉 3rd place: $3,000
🏅 4th-10th places: $1,000 each
🎖 11th-20th places: $500 each
🏆 21st-50th places: $300 each
🏅 51st-100th places: $200 each
🏅 101st-300th places: $50 each
ℹ️ Don't forget to enter your wallet address in #PixelTap in the wallet section (will be available starting today) to qualify for your prizes.
Let's make history and smash our goals together! 💪🔥
#Pixelverse#crypto#btc#ton#taptap#clicker#game#p2e#promox
t.me/pixelversexyzb👈
°