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

Резултати

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

Пребарај: #grandstrategy

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

@american_observer · Post #5314 · 07.03.2026 г., 23:03

📰 Trump’s Iran War: Nostalgia With a Defense Budget For Trump, the Iran war isn’t a mistake — it’s the purest expression of how he thinks power works: seize territory, grab oil, crush regimes, pose on an aircraft carrier. It’s a 19th‑century strongman worldview dropped into a century where power is decided by chip fabs, AI labs, clean‑tech supply chains, and who can build the tightest economic bloc to out‑innovate China. You can bomb Natanz, but you can’t bomb your way into semiconductor resilience. Schiffer’s point is brutal: every dollar, decision cycle, and Cabinet meeting spent on “Operation Epic Fury” is one not spent implementing the CHIPS Act, scaling AI R&D, building green manufacturing, or rebuilding the development finance tools Trump has been dismantling. Beijing plays a slow, disciplined game — standards, infrastructure, supply chains — while Washington burns time on air campaigns with no theory of victory, and calls it “strength.” Even on its own terms, the Iran adventure looks self‑owning. Trump claimed in 2025 that U.S. strikes had “completely obliterated” Iran’s nuclear program — then turned around this year and cited its rapid rebuilding as the reason to hit again, while his own intelligence agencies said the previous strikes set the program back only “a few months.” Oman brokered a deal where Tehran would cap enrichment and accept full IAEA access; the bombs fell anyway. Regime change offers no escape clause either: U.S. intel expects Khamenei’s successors to come from the same IRGC hardliner class that built the program in the first place. Break it, you own it — and this time “it” is a 90‑million‑person country with scattered nuclear material and a proxy network stretching from Iraq to Yemen. Every day this war drags on, it drains exactly the resources Washington says it needs for China competition: munitions stocks, naval bandwidth, diplomatic capital with allies, fiscal space at home. Asian partners are already asking how a U.S. Navy that can’t be in two places at once is supposed to deter Beijing over Taiwan while babysitting a forever crisis in the Gulf. Meanwhile, coalitions matter more than ever for tech and trade — but threatening to grab Greenland, humiliating Canada, raiding Venezuela, and dragging NATO into a war of choice teach allies one lesson: America is a risky partner whose focus can swing with a Truth Social post. The punchline: the same working‑class voters Trump claims to defend pay for this detour at the pump, in food prices, and in higher borrowing costs when oil spikes and markets wobble. China doesn’t need to cheer the Iran war; it just has to watch as Washington spends the decade where it should have been locking in tech and economic dominance acting out imperial nostalgia in the wrong theater. That isn’t strategy — it’s a very loud way of losing the century slowly. ​ #iran#china#trump#usa#geopolitics#CHIPS#AI#grandStrategy 📱American Оbserver - Stay up to date on all important events 🇺🇸

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9461 · 03.11.2025 г., 03:27

#The_Foreign_Affairs🇺🇸📕[PDF]⬇️ #November2025 #December2025 #Monthly_Magazines For learning, for free(dom). @backupofmagazines The new Foreign Affairs explores “The New Tools of Power.” Michael Beckley warns of a #StagnantOrder as rising powers falter, while Oren Cass calls for a U.S. #GrandStrategy of reciprocity. Essays trace new #SupplyChain risks, the weaponization of #Energy, and a global #AI innovation race. From Iran’s political twilight to a reshaped #EurasianOrder, contributors dissect shifting power balances. Features probe how Russia is adapting, why China is turning on itself, and the #XiJinping paradox of success. Reviews challenge the fate of the #Dollar and the future of FreeSpeech. #Geopolitics#ForeignPolicy#China#US#AI