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

Резултати

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

Пребарај: #gton

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

@tonlines · Post #7713 · 04.12.2025 г., 16:44

⚡️Gatto | Official Channel: $GTON Mine Event Details #GTON#TON The $GTON Mine event by Gatto | Official Channel offers players a chance to earn massive starting rewards and additional bonuses for successful captures, including TON rewards and items like the Delicious Gattobox. The event runs from 17:00 to 18:00 UTC. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7674 · 01.12.2025 г., 19:47

⚡️Gatto Official Channel: Final Chance for $GTON Rewards #GTON#TON Gatto Official Channel announces the delayed snapshot date for $GTON participation. Participants have until December 2nd to adjust their game balance and qualify for a range of rewards, including pets, food, and NFTs. Staking concludes on December 29th. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7554 · 21.11.2025 г., 10:06

Gatto Official Channel: Legendary Crocottery Event #TON#GTON The Gatto Official Channel announces the Legendary Crocottery event, a unique lottery where participants can win special prizes. Tickets are available for purchase with $GTON and TON, offering rewards such as gold coins, rare resources, and even Gen 9 pets. The event will culminate in a raffle on November 24th. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7461 · 30.05.2025 г., 18:18

⚡️Gatto Official: Prize Marathon Results #TON#GTON The Gatto Official Channel announces the results of the prize marathon for Doge Pound pet owners. Participants had the chance to win various sets of $GTON and TON, with rewards being distributed by the end of the day. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7385 · 27.05.2025 г., 09:11

⚡️Gatto Official Channel: Special Promotion for Krogurchikus Goods #TON#GTON Gatto Official Channel announces a two-day event featuring special items from Krogurchikus at discounts up to 80%. A unique "Shopaholic" promotion offers the chance to double your purchases by buying at least one item in each category, including food, mutagens, and gattoboxes. The event begins at 10:00 UTC with a restock on May 28 but reduced quantities. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7298 · 20.05.2025 г., 14:39

⚡️Gatto | Official Channel: Exciting Gattobox Sales and Promotions #GTON#TON Gattoboxes are set to go on sale with two thrilling promotions. Participate in the "Who's Bigger" promotion by purchasing more gattoboxes than others to win mutagens and rare items. Additionally, try your luck in the "Lucky Chance" raffle by buying at least one GTON or TON gattobox. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7447 · 30.05.2025 г., 11:04

Gatto: May $GTON Staking Rewards Completed #GTON#NFT The Gatto channel has announced the completion of the May $GTON staking, with participants receiving various in-game rewards and personalized recognitions. Long-term staking awards will also be distributed, with the next staking round set to begin on June 1. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7697 · 03.12.2025 г., 15:46

Gatto | Official Channel: Creative Contest Announcement #Gatto#GTON Gatto | Official Channel has announced a creative contest to celebrate a birthday, inviting talented individuals to participate by creating drawings, stories, and crafts dedicated to Gatto. Participants are categorized by age, with the chance to win $GTON rewards. Submissions are open until December 8th. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6778 · 15.04.2025 г., 13:50

⚡️Gatto Official Channel: PvP Battle Event with Rewards #GTON#Gatto The Gatto Official Channel invites players to join a special PvP event starting at 14:00 UTC. Participants who defeat the GTeam in consecutive battles can earn various rewards, including Silver Coins, Legendary Gattoboxes, and more. The event takes place exclusively on the European server and runs until April 15, 15:00 UTC. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7648 · 29.11.2025 г., 12:12

Gatto | Official Channel Staking Update for December #staking#GTON Gatto | Official Channel announces a staking event in December for $GTON token holders. Participants can earn various rewards, including exclusive prizes and in-game items, by holding tokens from December 1st to 29th. Source: link @tonlines

TONlines – News

@tonlines · Post #7647 · 29.11.2025 г., 12:12

Gatto: December Staking Rewards Begin December 1 #staking#GTON Gatto | Official Channel announces a new staking initiative for $GTON, starting on December 1 and running until December 29. Participants will be rewarded with various prizes, including game items and tokens, depending on their stake tier. Source: link @tonlines

TONlines – News

@tonlines · Post #7642 · 28.11.2025 г., 15:33

Gatto | Official Channel: November $GTON Staking Completion #staking#GTON The Gatto | Official Channel successfully concluded the November $GTON staking event. Participants maintained their tokens on game balances and earned rewards like gold coins and gattoboxes. The next staking begins on December 1st, with more information on rewards coming soon. Source: link @tonlines

ПретходнаСтраница 1 од 3Следна