Что делать если нужно поставить какую-то 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
❄️ Arctic Spin is Coming Soon! ❄️
We’re thrilled to announce Arctic Spin, our frosty new 3x3 slot, launching on the 14th November! With sleek winter visuals, variable paylines, and fast-paced gameplay, this game delivers a cool twist on classic slots. Get ready to spin through the snow and uncover some frozen treasures! ❄️🎰
⛄️ Stay tuned for updates!
#ArcticSpin#ComingSoon#TrueGames#TrueLab#TrueSlots
⚔️Battle Rage: new game — new UI
⚡️ Our yet to be released game Battle Rage will feature a completely revamped user interface! This is the first game to debut with our fresh, modern design — and trust us, it’s sleek, user-friendly, and visually stunning 🔥
🎮 Unlike many other providers, our new UI will offer a smooth and enjoyable top-notch experience, giving us a major edge in the gaming world.
💯 Not to mention that Battle Rage is set to be the hit of the year! Your favorite streamers will be playing it online, including the legendary Eddie from Stake. So, don't miss out! 💣
➡️ TRY DEMO NOW!
Coming very soon!
#BattleRage#newgame#comingsoon#TrueLab#TRUEGames
Get hooked on Fishy Business' Hold'n'Win respins! With every landed coin, your 3 respins reset, keeping the action alive and swimming! Complete all reel positions for a shot at the x1000 jackpot!
Ready to reel in the big one? Fishy Business launched on August 22nd! 🎰💦
Give it a go! https://bit.ly/fishy-business-demo
#FishyBusiness#HoldnWin#ComingSoon#TrueSlots#TrueGames#TrueLab
🔞 | Play Responsibly
Only 3 Days Until FRUIT CIRCUS PARTY! 🍉🎪
Why wait for the fun? The Buy Bonus feature lets you jump straight into the bonus round, where multiplicative multipliers never reset between spins. More spins, more multipliers, more mayhem! 🎢
Tick-tock, the madness begins in just 3 days. June 27th – mark the date!
➡️DEMO: https://bit.ly/demo-fcp
#FruitCircusParty#MultiplicativeMultipliers#BuyBonus#TrueLab#TrueGames#TrueSlots
Fishy Business is OUT NOW! 🐟💰
No more waiting—our top catch of the year has surfaced! Fishy Business delivers high volatility undersea action with 25 paylines, Hold'n'Win thrills, and a shot at x5000 max wins. The Bassline Bonanza Free Spins make this one dive you won’t want to miss, as reels 2, 3 and 4 convert into one huge symbol for some truly huge wins! 🌊⚡
Ready to take the plunge? 🤿
🎰 SPIN IT: https://bit.ly/fishy-business-demo
#FishyBusiness#OutNow#HoldnWin#TrueSlots#TrueGames#TrueLab
🔞 | Play Responsibly
The Wait is Over — Hot Devil Slot is Here! 😈
Kick off our HOT Series with a spin that’s hotter than your ex and easily twice as fun. Ready to play with fire or just here to warm up? With classic gameplay turned up to inferno levels, every spin is destined to thrill.
Let the games begin! 🔥
🍒 IGNITE THE FUN: https://play.truelab.games/game/hot-devil-slot-v1/static/index.html
#HotDevilSlot#OUTNOW#igamingnews#TrueLab#TrueSlots#TrueGames
🔞 | Play Responsibly
🎃 Happy Halloween, thrill-seekers! 🎃
Tonight’s the night to embrace the spooky spirit, and what better way than with Wild Pumpkins Deluxe? Our Halloween-themed slot is packed with sticky wilds, multipliers, and more ways to win than you can shake a broomstick at.
Forget the candy—tonight’s treat is big win potential! Brave enough to give it a spin?
Play Wild Pumpkins Deluxe and let the haunting begin! 👻
🎰GIVE IT A SPIN:https://bit.ly/wpd-demo
#HappyHalloween#WildPumpkinsDeluxe#TrickOrTreat#TrueLab#TrueGames
FRUIT CIRCUS PARTY brings fruit carnage to a whole new level! Step right up, there's a new circus in town! 🎪
Cascading wins unlock fresh combos & crank up the multipliers. Madness begins June 27th! 🗓️
➡️ DEMO: https://truelab.games/games/fruit-circus-party
#FruitCircusParty#CascadingWins#MultiplierChaos#TrueLab#TrueGames#TrueSlots
Only one week left until HOT MONEY hits the scene on June 13th!
Classic fun meets new age looks in the second game of our Hot Series. It's going to be a hot blast from the past, but better. 🔥
Demo Dropped! Check it: https://truelab.games/games/hot-money-slot
#HotMoney#AlmostHere#iGamingNews#TrueGames#TrueSlots#TrueLab
We’re thrilled to announce the upcoming launch of our next game, HOT HAMSTER, on the 11th of September, 2024! 🔥🔥
This game is a bonus addition to our TRUELAB HOT SERIES offering of classic games, and it features 30 variable lines and an expanding wild that grows to cover the entire reel! Easy to understand and fun to play - the essence of what the classic series is meant to be.
🎰 SPIN IT: https://bit.ly/hot-hamster-demo
#HotHamster#ComingSoon#ExpandingWild#TrueClassic#TrueGames#TrueSlots
🔞 | Play Responsibly
BOOM! The Fruit Circus Party is in town tonight! 💥
The wait is over, so It's finally time to unleash those unlimited multiplicative multipliers and kick off the mayhem!
Use the Buy Bonus to plunge straight into the bonus round, where multipliers only head in one direction - UPWARDS. Because who needs limits, right?
Fruit Circus Party is OUT NOW! 🚀
➡️ SPIN IT: https://bit.ly/demo-fcp
#FruitCircusParty#OUTNOW#MultiplicativeMultipliers#BuyBonus#TrueLab#TrueGames#TrueSlots
🔥💸 Feeling Lucky? More like feeling HOT! 💸🔥
HOT MONEY SLOT, the second game in TrueLab’s Hot Series, is OUT NOW. We’ve taken those good old fire and fruit line 3x3 mechanics and turned up the heat with top-notch graphics and sound.
The Hot Series games are the perfect complement to any game portfolio. Do you prefer quick action with a classic vibe but can't get yourself to revisit the oldies? This one's for you. Let's go. 🎰
➡️ SPIN IT: https://bit.ly/Hot-Money-Demo
#HotMoneySlot#OutNow#HotSeries#iGamingNews#TrueLab#TrueGames#TrueSlots
🔞 | Play Responsibly