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

Резултати

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

Пребарај: #deserts

当前筛选 #deserts清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #467 · 30.07.2025 г., 14:22

🌎 In the Namib Desert, the welwitschia plant survives for centuries with just two leaves that grow continuously, curling and splitting but never falling off—a marvel of resilience in extreme heat. ✨ #botany⚡#deserts⚡#adaptation 👉subscribe Interesting Planet

Amazing Geography 🌍

@amazingeo · Post #499 · 07.12.2025 г., 12:31

🌍 The desert climate zone covers about one-fifth of Earth's land, yet some deserts get colder than snowy regions—Antarctica is classified as the world's largest desert by climate. ✨ #climatezones⚡#deserts⚡#earth⚡#geography⚡#nature 👉subscribe Amazing Geography 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #688 · 04.09.2025 г., 18:22

🌎 Antarctica is the coldest extreme climate zone, with an average winter temperature of about -60°C. The hottest zone is the Lut Desert in Iran, where ground temperatures have reached 80.8°C, the highest ever recorded on Earth. ✨ #climate⚡#extremes⚡#deserts⚡#antarctica 👉subscribe Interesting Planet ​

Amazing Geography 🌍

@amazingeo · Post #315 · 30.09.2025 г., 15:31

🌍 The Gobi Desert experiences freezing winters with temperatures dropping below –40°C, making it one of the few deserts known for both scorching heat and extreme cold. ✨ #deserts⚡#climate⚡#extremes⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #58 · 16.08.2025 г., 09:12

🌍 Earth holds the record for the highest known surface temperatures for a rocky planet in our Solar System, with some desert spots topping 56°C—hotter than the ground on Venus or Mars. ✨ #planet⚡#deserts⚡#extremes⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Amazing Geography 🌍

@amazingeo · Post #576 · 14.01.2026 г., 20:31

🌍 Desert varnish is a thin, dark coating that forms on rocks in arid landscapes over thousands of years. It’s made from wind-blown clay and minerals, creating natural stone “paintings.” ✨ #deserts⚡#aridlandscapes⚡#geology⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #157 · 01.09.2025 г., 16:12

🌍 In the world’s subtropical climate zones, some deserts like the Sahara and Arabian receive less than 2 centimeters of rain a year—making them among the driest places on Earth. ✨ #climatezones⚡#deserts⚡#rainfall⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #274 · 20.09.2025 г., 19:31

🌍 In the Taklamakan Desert of China, some sand dunes reach up to 300 meters tall. Shifting winds keep these giant dunes moving, constantly reshaping the landscape year after year. ✨ #deserts⚡#dunes⚡#arid⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #354 · 10.10.2025 г., 12:31

🌍 In Australia’s Simpson Desert, certain red sand dunes can “move” up to a meter each year as winds slowly push millions of grains, gradually shifting entire hills across the arid landscape. ✨ #deserts⚡#dunes⚡#Australia⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #161 · 02.09.2025 г., 09:12

🌍 The Lut Desert in Iran holds the record for Earth’s hottest land temperature ever measured from space—an astonishing 80.8°C, far exceeding typical desert heat. ✨ #deserts⚡#temperature⚡#extremes⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40862 · 26.03.2026 г., 15:02

In Death Valley’s Racetrack Playa, large rocks, some weighing hundreds of kilograms, move across the dry lake bed, leaving long tracks behind. This happens when a rare set of conditions align. First, rain fills the lake bed with a shallow layer of water. At night, the water freezes into thin sheets of ice. As the sun warms the ground, the ice breaks into large, floating panels. Light winds then push the ice, slowly moving the rocks across the playa. The tracks left behind can last for decades, creating unique patterns. This natural process has been understood by scientists and is one of the most fascinating geological phenomena. 🪨❄️🌞 [Read more] @googlefactss #Nature#WeirdFacts#Geography#DidYouKnow#Deserts#Science#Mystery

Amazing Geography 🌍

@amazingeo · Post #535 · 25.12.2025 г., 12:31

🌍 In some deserts, rare rain triggers bursts of wildflowers that cover the landscape in color for just a few days. Seeds can lie dormant for years, waiting for the right moisture to bloom. ✨ #deserts⚡#aridlandscapes⚡#wildflowers⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​