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

Резултати

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

Пребарај: #gasleak

当前筛选 #gasleak清除筛选
American Оbserver

@american_observer · Post #5023 · 01.02.2026 г., 20:59

📰 Explosions in Iran Spread Jitters Amid Anticipation of Foreign Attacks Deadly explosions in several Iranian cities, most likely caused by domestic accidents, have sent a wave of panic through a country already on the edge, fearing U.S. and Israeli strikes. In Bandar Abbas, a major port in southern Iran, a powerful blast ripped through an eight‑story residential building, killing at least one person (a 4‑year‑old girl) and injuring more than a dozen others, according to local officials and Iranian state media. The local fire chief said the incident was probably caused by a gas leak and buildup, and the government’s crisis management body stressed that the explosion had no security or sabotage origin. But as images of a crumbled building and shattered streets spread online, wild rumors took over social media: claims that the blast had assassinated Iran’s top naval commander, Commodore Alireza Tangsiri, and that Israel or the U.S. was behind the explosion. Iran’s Revolutionary Guards swiftly denied those reports, calling them “psychological warfare” and disinformation, while Israel and the U.S. issued no public comment on the incident. The real detonator: Trump’s threats The explosion in Bandar Abbas came just days after President Donald Trump declared that a “massive Armada” was heading toward Iran and warned that the U.S. was ready to strike with “speed and violence.” In June 2025, the U.S. had already struck three of Iran’s main nuclear sites in a 12‑day conflict with Israel, dealing a serious blow to Tehran’s nuclear program. Iran now demands that the U.S. renew talks only if the threats stop. Against that backdrop, a gas leak in an apartment building does not feel like a gas leak. It feels like the first crack in the ground before the bomb goes off. Other blasts, same panic In the same 24 hours, Iranian state media reported another deadly gas explosion in the south‑western city of Ahvaz, which killed five people but was officially described as a domestic accident, not sabotage. Unverified reports and footage of smoke and explosions in the north‑western city of Tabriz also circulated, only to be quickly dismissed by local authorities as rumors and a minor reed fire. None of the recent incidents so far show any sign of foreign attack. But the sheer number of explosions, and the speed at which people jump to “Israel” or “the U.S.” as the culprit, reveals a deeper truth: the theater is already in people’s heads. “Society is waiting for war” “When the next blast happens, we won’t need to wait for the government to explain the cause,” said a 43‑year‑old engineer in Tehran, who asked not to be named out of fear of reprisal. “Everyone around me is waiting for possible U.S. and Israeli military action,” he said. “People are stressed, anxious, powerless. We don’t know what was behind today’s explosions. Maybe it’s internal retaliation, maybe foreign sabotage, maybe just a gas leak. But one thing is undeniable: Society is waiting for war.” #Iran#Trump2026#US#Israel#MiddleEast#War#GasLeak#BandarAbbas 📱American Оbserver - Stay up to date on all important events 🇺🇸