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

Резултати

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

Пребарај: #legends

当前筛选 #legends清除筛选
Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #39958 · 27.10.2025 г., 23:01

Today, exactly 100 years ago on the 28th of October 1925 the mask of Tutankhamun was discovered. There was a legend that those who disturbed the tomb would be cursed, soon after the discovery and disturbance of the tomb certain incidents in wich members of the team started dying made it seem that this legend was true. [read more here] @googlefactss#history#funfact#Egypt#legends

Interesting Planet 🌍

@interesting_planet_facts · Post #1319 · 27.02.2026 г., 12:11

🌎 The legend of Yamata no Orochi comes from ancient Japanese mythology and describes an enormous eight-headed, eight-tailed serpent defeated by the god Susanoo. According to the Kojiki and Nihon Shoki texts from the 8th century CE, Susanoo discovered the creature in Izumo Province and tricked it with sake before slaying it. Archaeological evidence indicates these texts are among Japan’s oldest written records. ✨ #mythology⚡#Japan⚡#legends 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #631 · 26.08.2025 г., 03:22

🌎 Ireland’s legend of the Salmon of Knowledge tells of a magical fish that granted wisdom to whoever tasted it. In Celtic mythology, eating this salmon gave the poet Fionn mac Cumhaill extraordinary wisdom, making him a great hero in Irish folklore. ✨ #mythology⚡#legends⚡#folklore 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #922 · 17.10.2025 г., 12:11

🌎 On the island of Flores in Indonesia, local legend tells of the Ebu Gogo—small, hairy people said to steal food and mimic speech. In 2003, scientists discovered Homo floresiensis fossils nearby, a tiny ancient human species, fueling debate about whether the myth preserves a memory of real prehistoric encounters. ✨ #legends⚡#anthropology⚡#indonesia 👉subscribe Interesting Planet 👉more Channels ​

🗺🐍Grootslang (Afrikaans and Dutch for “big snake”) is a legendary creature said to dwell in a deep cave in the Richtersveld region of northwestern South Africa, fiercely guarding its diamonds 💎 from treasure seekers. According to myth, the Grootslang was so powerful and cunning that the gods who created Earth decided to split it into two separate species — the elephant🐘 and the snake. 🐍 Yet some Grootslangs, the legends say, escaped into the deepest cave, where they have survived to this day. The cave is filled with diamonds 💎, but no one can reach them — the creature keeps watch day and night. 🌑✨ #Culture#Myths#SouthAfrica#Africa#Legends#Wildlife

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40775 · 11.03.2026 г., 15:04

Flexible glass was a legendary type of glass from ancient Rome. A craftsman is said to have invented it, and it could supposedly bend without breaking. He showed it to Emperor Tiberius, who reportedly asked him to confirm he was the only one who knew how to make it. The emperor then had him executed to prevent the invention from spreading, an early example of planned obsolescence. No known examples survive today. 🏺🪞📜 [Read more] @googlefactss #FlexibleGlass#AncientRome#History#Legends#Innovation

Interesting Planet 🌍

@interesting_planet_facts · Post #757 · 15.09.2025 г., 20:22

🌎 The Mapuche people of southern Chile and Argentina have long told of the mythical “Pillán,” powerful spirits linked to volcanoes and natural disasters. Early European chroniclers in the 16th century recorded beliefs that eruptions were caused by these spirits’ anger. The word “pillán” still appears in many local place names near active volcanoes. ✨ #Mapuche⚡#mythology⚡#volcanoes⚡#legends 👉subscribe Interesting Planet ​

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