Что делать если нужно поставить какую-то 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
🏆 GuPay Team Cup – 2025 FIFA Club World Cup Edition is LIVE! ⚽️
Choose your team. Power it with every transaction.
From the pitch to the blockchain — this is where Web3 meets real-world passion. ⚽️
🗓 June 9 – July 15, 2025
Support 1 of 32 legendary clubs from the official 2025 FIFA Club World Cup, use GuPay, and help your squad rise to the top!
🎯 How to join:
1️⃣Pick your favorite club by filling out the registration form: link
2️⃣ Make transactions using GuPay throughout the tournament
3️⃣ Each transaction boosts your team’s total score on the leaderboard
🎁 $5,000 Prize Pool
The entire reward will be shared among users who joined the team with the highest total transaction volume via GuPay during the campaign.
📌 Fill the form now to lock in your team choice: link
📊 Team standings and leaderboard will be updated regularly — stay tuned!
🌐 From sport to spending, culture to crypto — Gumart is bringing Web3 to real life, one goal at a time.
#GuPayTeamCup#GuGiveaway
🏆 GuPay Team Cup – FIFA Vibes, $5,000 Prize Pool! 📈
Something big is coming to GuPay... and it’s dressed in jerseys, flags, and fire.✨
⚽️ 32 teams - inspired by the world of FIFA
💥 Fierce competition, full of national pride
💰A massive $5,000 prize pool waiting at the finish line
Choose your team. Make your moves.
Support your side and help them rise to the top.
Can you guess what’s coming? Stay tuned 👀
#GuPayTeamCup#GuGiveaway
🛍 GuPay Team Cup – Midway Update: Who’s Leading the Race?
It’s been nearly three weeks since the GuPay Team Cup kicked off - and the competition is getting intense! With thousands of Gumart residents rallying behind their favorite FIFA clubs, the blockchain scoreboard is anything but predictable. ⚽️💸
Here’s the current Top 4 (by GuPay transaction volume):
🥇 Real Madrid – Still leading with unstoppable momentum
🥈Chelsea – Not far behind, showing strong team spirit – A surprise rise from Africa
🏅Al Hilal SFC – Consistency and strategy paying off
🏅Manchester City – Still showing its strength
🎉Remember: $5,000 prize pool will be distributed to users who joined the team with the highest total GuPay transaction volume by the end of the tournament.
🚀 Don’t forget to:
✅ Register your team: link
✅ Transact with GuPay before July 15
✅ Watch the leaderboard change in real-time
From football fields to financial freedom — this is Web3 in action, where fans aren’t just cheering, they’re shaping the outcome. ✋
🏁 2 weeks left. One winner. Will it be your team?
#GuPayTeamCup#GuMinigame#FIFAClubWorldCup2025
🏆 GuPay Team Cup – The Race Is On! ⚽️
Just 3 days in, and over 2,000 Gumart residents have jumped into the GuPay Team Cup – 2025 FIFA Club World Cup Edition!🚀
🔥 The leaderboard is heating up:
1️⃣ Real Madrid is leading the charge
2️⃣ Chelsea right behind
3️⃣ Manchester City chasing hard!
Want your team to rise? 💥
👉 Every GuPay transaction boosts your team’s score and brings you closer to the $5,000 prize pool!
📍Choose your team now and start transacting: link
#GuPayTeamCup#GuGiveaway#FIFAClubWorldCup
‼10,000+ TRANSACTIONS IN 20 DAYS 🤑
GuPay Team Cup – FIFA Club World Cup 2025 is going global - and it’s powered by BNB Chain ⚡️
From Real Madrid to Man City, 32 legendary football clubs are battling it out. But this time, it's not just on the field — it's on-chain. 🏟
📣 Gumart is rewriting what mass adoption looks like:
10,000+ real-world transactions made through GuPay across hotels, stores, and events — all in less than 3 weeks.⬆️
🚀 Built on BNB Chain's trusted infrastructure, Gumart is leading the charge in making crypto usable, visible, and impactful in everyday life.
➖Want to join?
Pick your team and make transactions with GuPay. Help your squad rise to the top.
🌐 Be where culture, payments, and crypto collide.
#GuPayTeamCup#Gumart#BNBChain