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

Резултати

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

Пребарај: #earthquake

当前筛选 #earthquake清除筛选
Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3061 · 17.08.2024 г., 19:47

A powerful 7.4 magnitude earthquake has struck 107 km ESE of Petropavlovsk-Kamchatsky, Russia, near the Kamchatka region. Local authorities are closely monitoring the situation due to the risk of significant aftershocks and potential tsunamis. #Earthquake#Russia

Interesting Planet 🌍

@interesting_planet_facts · Post #707 · 07.09.2025 г., 20:22

🌎 After a 2010 earthquake in Haiti, a pig named "Lucky" survived buried under rubble for 27 days. He lived by eating charcoal and licking moisture from debris until rescue workers pulled him out alive. ✨ #survival⚡#animals⚡#earthquake 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1048 · 17.11.2025 г., 22:11

🌎 The 1755 Lisbon earthquake was one of the most destructive natural catastrophes in European history. The quake, followed by a tsunami and fires, destroyed much of Lisbon and killed up to 50,000 people. Its impact led to major advances in seismology and influenced Enlightenment thinking about disasters. ✨ #earthquake⚡#tsunami⚡#history 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #900 · 12.10.2025 г., 22:11

🌎 An enormous tsunami struck the Indian Ocean on December 26, 2004 after a magnitude 9.1 earthquake off Sumatra. Waves up to 30 meters high inundated coasts in 14 countries, killing over 230,000 people and displacing millions, making it one of the deadliest natural disasters in recorded history. ✨ #tsunami⚡#earthquake⚡#history 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #807 · 24.09.2025 г., 15:11

🌎 Trapped under debris for 17 days after a 2015 Nepal earthquake, Pemba Tamang survived by drinking muddy water dripping from rubble and eating small snacks. He emerged with only minor injuries after nearly 2½ weeks underground, making it one of the longest earthquake survival cases recorded. ✨ #survival⚡#earthquake⚡#resilience 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #506 · 10.12.2025 г., 20:31

🌍 The 2018 Sulawesi earthquake in Indonesia triggered a rare "soil liquefaction," turning solid ground into a flowing sludge that swallowed entire neighborhoods beneath muddy waves. ✨ #disasters⚡#earthquake⚡#liquefaction⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #433 · 04.11.2025 г., 12:31

🌍 Earthquakes under the ocean can create tsunamis—giant waves traveling at jet speed. A tsunami may cross an entire ocean before reaching land with just minutes’ warning. ✨ #tsunami⚡#earthquake⚡#hazards⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #359 · 11.10.2025 г., 15:31

🌍 The 1811–1812 New Madrid earthquakes in the central United States were so powerful they briefly made the Mississippi River flow backward, reshaping the landscape far from any plate boundary. ✨ #disaster⚡#earthquake⚡#river⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40448 · 31.12.2025 г., 19:01

The 2011 Japan earthquake (8.9 magnitude) made Earth spin faster, shortening the day by 1.8 microseconds. It moved Japan’s main island 8 feet and shifted Earth’s axis by 6.5 inches. The 2010 Chile quake (8.8) and 2004 Sumatra quake (9.1) also shortened the day by small amounts. Earthquakes change Earth’s mass, making it spin quicker like a figure skater. 🌍⏱️ [Read more] @googlefactss#Earthquake#DayLength#EarthRotation

Interesting Planet 🌍

@interesting_planet_facts · Post #1138 · 17.12.2025 г., 18:11

🌎 The Tōhoku earthquake and tsunami struck Japan on March 11, 2011, with a magnitude 9.0 quake and waves up to 40 meters. This disaster caused over 15,000 deaths, triggered the Fukushima nuclear accident, and shifted the Japanese coast by up to 2.4 meters. ✨ #earthquake⚡#tsunami⚡#fukushima 👉subscribe Interesting Planet 👉more Channels ​

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