Что делать если нужно поставить какую-то 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
❤️TON Dating launched on Telegram
The former head of VK Dating launched a new dating application on the TON blockchain in #Telegram.
To create a profile, you need to go through multi-step verification. As Makhov explains, the identity verification algorithm works according to the principles of online banking. To register, you need to provide your first and last name, Instagram profile, upload three photos and send a selfie.
Girls can use TON Dating for free, and for men a monthly subscription will cost 2500 Stars⭐️(€57.99). At the same time, users can monetize their actions in the application.
For “friend invitations,” “likes,” and “matches,” the service pays a reward in the Toncoin cryptocurrency, the size of which depends on the activity.
Investments in developing the application amounted to $100 thousand. Payments of rewards are made through the redistribution of part of the money from subscriptions. According to the founder, within three years #TONDating plans to attract at least 0.1% of Telegram and #TON users from the CIS countries, the Middle East, North Africa, Europe and Asia.
The service pays rewards in #Toncoin for user actions, so if you still like for free on Tinder, then it's for you❤️
@tondating✔️
🎧⤴
TON Dating Unleashes New Filters—Are They Revolutionizing Online Matchmaking?
- New Filters:TON Dating introduces advanced filters including industry, height, eye color, and zodiac sign. Age and location filters now have an automatic expansion option.
- Enhanced Matching: Improved visibility for interest matches and likes, making it easier to find mutual connections. Men can also filter to see only those who liked them.
- User Experience: A new profile preview feature lets users see how their profiles appear to others. Registration for men no longer requires an Instagram account, simplifying the process.
Verse 1:
Filters on deck, yeah, I'm swiping with finesse,
Height, zodiac, eyes—got my standards, nothing less.
Profiles poppin', see who likes you in a sec,
Match, earn that Toncoin, yeah, we chasing that check.
Chorus:
Swipe right, match tight, filters in the night,
Crypto in my wallet, future looking bright.
TON's the app, making moves, keeping it tight,
Find your match, make it last, everything's in sight.
Verse 2:
No 'gram needed, just a smile and a vibe,
Men, you know who likes you, keep that energy high.
Interest matches lit, common ground we can't deny,
On this blockchain journey, love and money coincide.
Chorus:
Swipe right, match tight, filters in the night,
Crypto in my wallet, future looking bright.
TON's the app, making moves, keeping it tight,
Find your match, make it last, everything's in sight.
Bridge:
From the chat to the heart, blockchain sets us apart,
Earnin' while you lovin', that's the realest art.
Step up your game, don't let this chance slip away,
TON Dating's the wave, it's a brand-new day.
#TONDating
#Dating
#Ton
🎧@toncoin_rap
🎧⤴
TON Dating: AI-Powered Compatibility Checks with ChatGPT!
TON Dating has become the first dating app to integrate ChatGPT, offering a new feature that analyzes compatibility between users. By clicking on the ChatGPT icon in a profile, the AI examines both users' data to determine their match potential. This move aims to enhance the dating experience within a verified, secure community that rewards user engagement with cryptocurrency. The integration sets TON Dating apart, offering a futuristic, AI-driven approach to finding meaningful connections on the platform.
😴👉https://t.me/tondating
Chorus:
TON Dating's blowing up, with ChatGPT inside,
AI's your new matchmaker, taking love on a ride.
Swipe right, swipe left, let the AI decide,
Finding true connections where ambition and love collide.
Verse 1:
Step into the game, TON's raising the stakes,
AI compatibility, no more heartbreaks.
Profiles verified, no scammers in sight,
Pay-to-play, yeah, but it feels just right.
Girls roll free, boys paying their dues,
Crypto rewards for every match you choose.
Swipe with intention, love or coin’s the prize,
TON Dating's got the edge, no surprise.
Chorus:
TON Dating's blowing up, with ChatGPT inside,
AI's your new matchmaker, taking love on a ride.
Swipe right, swipe left, let the AI decide,
Finding true connections where ambition and love collide.
Verse 2:
Ambition meets beauty, the motto’s legit,
Profiles vetted hard, so no catfish hit.
Vlad’s got a vision, safe space to thrive,
No fake accounts here, just the real ones alive.
Stack your TON coin, let your profile shine,
The app’s got your back with AI design.
Success and smarts, it’s the ultimate find,
TON Dating’s got that AI mastermind.
Chorus:
TON Dating's blowing up, with ChatGPT inside,
AI's your new matchmaker, taking love on a ride.
Swipe right, swipe left, let the AI decide,
Finding true connections where ambition and love collide.
Verse 3:
Crypto’s the future, and dating’s the key,
Bringing people closer through technology.
ChatGPT whispers, "Is this love or a game?"
It’s matchmaking magic, never quite the same.
Filter out the fakes, meet your match on screen,
High standards, high hopes in this dating scene.
From Telegram to TON, the platform's tight,
Find your perfect vibe, under AI light.
Chorus:
TON Dating's blowing up, with ChatGPT inside,
AI's your new matchmaker, taking love on a ride.
Swipe right, swipe left, let the AI decide,
Finding true connections where ambition and love collide.
Bridge:
So step up to the future, the game just begun,
With ChatGPT matching, you might find "the one."
It’s a new world, new rules, tech by your side,
TON Dating’s the place where love and crypto collide.
#TONDating#AIDating#ChatGPTMatch
#TONCryptoNewsRapStyle
🎧@toncoin_rap