TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #210 · 3 фев.

Что делать если нужно поставить какую-то 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

Резултати

Пронајдени 3 слични објави

Пребарај: #toncommunity

当前筛选 #toncommunity清除筛选
TONlines – News

@tonlines · Post #6856 · 19.04.2025 г., 17:00

STON.fi Celebrates Successful Event in Tbilisi #TON#Tbilisi#TONCommunity At the recent meet-up in Tbilisi, STON.fi brought together the TON community with passionate discussions and showcases of innovative projects. The event, co-hosted by TON Georgia, highlighted the diversity of voices contributing to the growth of the TON ecosystem. Source: link @tonlines

TON Crypto News

@toncoin_rap · Post #195 · 20.10.2024 г., 09:19

🎧⤴ 💎 Telegram’s Crypto Bot Launches Fee-Free Coin Swaps – Best Rates on TON and Beyond! Telegram’s popular Crypto Bot introduced a groundbreaking Swap feature, enabling seamless exchanges of cryptocurrencies, including TON, at optimal market prices with 0% commission. This new feature empowers users to swap tokens effortlessly, catering to the needs of both seasoned traders and beginners. As Telegram strengthens its ties with The Open Network (TON), this development marks a significant step towards making zero-fee crypto trading more accessible and user-friendly. TON, Telegram, and crypto swaps headline this exciting update. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Verse 1: Telegram’s bot, now it’s all in play, Swappin’ TON coins without delay. Zero fees stack, in a major way, Crypto’s here to stay, what more to say? Swipe right, the trades ignite, Swappin' at the best rates, day or night. TON on deck, the moves in sight, Crypto bot’s game changin’, feelin’ right. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Verse 2: From TON to ETH or BTC, quick like a flash, One tap on Telegram, and the coins clash. Zero fees givin' more green in the stash, Crypto bot’s hustle, bringin’ in cash. Telegram links up with TON, Best swaps, no cap, just get it done. In the market, bots always on the run, Swappin’ coins, and we're havin' fun. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Verse 3: Telegram and TON, now we’re connectin’, Coins on the move, the fam’s respectin’. Best rates, zero fees, no second-guessin’, Crypto's risin', it's impressin'. Swap so quick, it’s like a race, Crypto bot's here, savin' time and space. TON's in the mix, the market’s embrace, With zero fees, everyone finds their place. Chorus: Swap it, drop it, no fees, we poppin’, Crypto bot’s live, TON fam’s watchin’. Best market rates, yeah, that’s the notion, Zero percent, ridin’ this motion. Bridge: TON in the mix, we set the tone, Zero fees, we break the stone. Crypto bot's king on this throne, This is the future, watch it be known. #TONCommunity#CryptoSwap#TON #TONCryptoNewsRapStyle 🎧@toncoin_rap

🙏SBT ONTON in real time! 🔍 Our chat has a bot that monitors the emergence of new SBTs in real time — they appear instantly along with passwords! ❤️ No need to search for them in different chats anymore - just join our community and get valuable Soul Bound Tokens to your wallet, so that you can get a drop for them later! 🟣Claim your SBT ONTON now! #TON#ONTON#SBT#Airdrop#Web3#TONCommunity