Что делать если нужно поставить какую-то 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
🔥 Hey everyone, we've got some awesome news! Now you can switch the bot's AI model from gpt-4o-mini to gpt-4o, o1, or o3 using the command below:
/model
🚀 Yup, you heard that right! It’s like choosing from different ice cream flavors—each one has its own irresistible taste! 🍦
❓ Do you want fast and playful answers with gpt-4o-mini? Or are you after precise and calculated responses with gpt-4o? Maybe you're in the mood for a unique vibe with o1 or o3? The choice is all yours!
🙂 So, let's have some fun and see which model suits your style best. If you have any questions or even a cool joke, feel free to share it with us at:
🤩@OpenAI_helpdesk
GPT_o3_mini:
• Smarter than 90% of people
• Speed: 3/5
• Cost: about 90X
GPT_o1:
• Super smart but a bit slow (Speed: 1/5)
• Supports images
• Cost: about 300X
GPT_4o_mini:
• Our main ChatGPT engine
• Super fast (Speed: 5/5)
• Supports images and free tokens
• Only costs 150X!
GPT-4o:
• Speed: 4/5
• Intelligence: 3/5
• Supports images and free tokens
• Cost: about 36X per word + 900X per request
💱 You might end up with too few tokens, so it's better to buy tokens right away to fully enjoy all the bot's awesome features.
☺️ Stay happy and enjoy the bot!
➖➖➖➖🔻
💎@Chatgpt_OfficialNews – Stay Updated! ⚡️
🧠 BOT: @Chatgpt_OfficialBOT
#️⃣#ChatGPT#AI#OpenAI#TokenSystem#CryptoPayments#BotSupport#Update
➖➖➖➖🔺
🌟 Exciting News for Our Users! 🌟
We’ve upgraded our system with a token mechanism for seamless usage! 🎉 Here's how it works:
💡 Tokens are deducted based on the number of characters in your question and the bot’s response.
📥 Daily Bonus: Every day, you’ll receive a free token refill to keep chatting without interruptions!
💳 Recharge Options: You can now top up your balance using Telegram Stars and cryptocurrency payments (BTC, ETH, USDT, and more)! 🚀
Enjoy more flexibility and freedom with this new system. Thank you for being part of our community – stay tuned for more updates! 💬
➖➖➖➖🔻
💎@Chatgpt_OfficialNews – Join Us! ⚡️
🤖 BOT: @Chatgpt_OfficialBOT
📱#ChatGPT#AI#OpenAI#TokenSystem#CryptoPayments#BotSupport#CommunityDriven
➖➖➖➖🔺
#Advertisement
Secure Your Crypto with Paycio! 🔒
Paycio ensures you can send and receive digital assets quickly and securely using just your mobile number. Whether you're a beginner or an expert, Paycio makes it easy.
Join the crypto revolution with Paycio!
🌐 Website: https://www.paycio.com
🤖 Install the app from here: https://play.google.com/store/apps/details?id=com.paycio
#Paycio#CryptoSecurity#Trust#CryptoPayments#SecureTransactions
🚀 Exodus Launches Self-Custody Payments App for Bitcoin and Stablecoins
Exodus has introduced a new self-custody payments application, enabling users to spend Bitcoin and dollar stablecoins. According to NS3.AI, the app is compatible with merchants that accept Visa and Apple Pay, providing a seamless payment experience for cryptocurrency holders.
#Exodus#Bitcoin#Stablecoins#SelfCustody#CryptoPayments#Visa#ApplePay#Cryptocurrency#BTC
Thailand Considers Bitcoin Tourism Pilot
Thailand eyes Bitcoin pilot in Phuket, focusing on tourism, despite the Bank of Thailand's ban on crypto payments. Supported by Binance Thailand CEO. Read more here.
#Thailand#Bitcoin#Thaksin#Phuket#Binance#CryptoPayments#Tourism BankOfThailand #PilotProject
🚀 Welcome to the Future of Communication & Payments with Liberdus
🔐 A decentralized messaging + payment platform built for privacy, speed, and freedom.
✨ Features: • End-to-end encrypted messaging
• Instant crypto payments
• Decentralized network
• Ultra low transaction fees
• Built on powerful Shardus technology
• Community-driven ecosystem
➡️ No central control. No censorship. Just secure communication and financial freedom.
⚡️ Liberdus is combining blockchain technology with real-world messaging utility to create the next generation of Web3 communication.
🔵Telegram: https://t.me/liberdusofficial
🔴 Website: http://liberdus.com
🐦 X: https://x.com/liberdus
#Liberdus#Web3#Crypto#Blockchain#DeFi#Messaging#Decentralized#Shardus#Privacy#CryptoPayments
Mining Project Linked to Notcoin?
Emerging mining project possibly linked to The Open Builders, but not confirmed. Design resembles their work. Early supporters encouraged to invest, but caution advised due to potential volatility. Bitcoin has hit a new all-time hashrate of 1000 EH/s, with 40% concentrated in the US led by Foundry USA at 36.5% share. China still holds a significant portion of Bitcoin mining. In other news, Coinbase is considering tokenized stocks for its Base blockchain, while Ethena announces new products including an institutional synthetic stablecoin and a Telegram-based app. Phantom wallet team denies rumors of an upcoming airdrop or token launch.
#Mining#Bitcoin#Cryptocurrency#Notcoin#TheOpenBuilders#Ethena#Stablecoins#PhantomWallet#COIN#Base#Funding#CryptoPayments#Investing#Hashrate#Blockchain#DeFi#CryptoNews#Tech#US#China#Foundry