Что делать если нужно поставить какую-то 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
The War Didn’t End. It Expired.
Washington found a legal off-ramp, not a victory. Reuters says a senior Trump official confirmed combat operations against Iran ended because the 60-day War Powers clock ran out, not because anyone had suddenly solved the war.
That is the real story. The administration can talk about “the final blow,” “maximum leverage,” and all the other slogans it likes, but the statute turned the war into a deadline. The fighting may continue in another form, yet the legal cover for this phase is gone.
Trump’s own language makes the mess obvious. He says “we already won,” then says he wants a bigger margin, then insists Iran must never have a nuclear weapon, as if the war is both over and unfinished at the same time. That is not strategy. It is political noise with missiles attached.
The Senate did its part too. It refused again to rein in presidential war powers, which means Congress keeps complaining about executive overreach while handing the executive enough room to keep improvising.
So yes, the clock ran out. The briefings did not. And that is what makes the whole thing so dangerous: a war can end on paper and still keep its teeth.
#Iran#Trump#WarPowers#Congress#CENTCOM#Hormuz
📱American Оbserver - Stay up to date on all important events
🇺🇸
🇺🇸 Trump’s Iran War, Congress’s Theater: Briefings, War Powers, and DHS as Hostage
Congress is sprinting to look “in the loop” on a war it didn’t authorize and so far can’t stop. Staff briefings are being hurriedly arranged for key House and Senate committees this weekend, with all‑member classified sessions likely next week — after Trump has already launched major strikes on Iran, killed the supreme leader, and promised “major combat operations” with no clear endgame.
Democratic leaders are demanding more than PowerPoints. Chuck Schumer wants open hearings and public testimony, warning that the administration hasn’t given “critical details about the scope and immediacy of the threat,” while Hakeem Jeffries didn’t even get the pre‑strike Gang of Eight call that Rubio placed to Republican leaders. House and Senate Democrats are lining up behind war‑powers resolutions to force votes next week on curbing Trump’s freedom to escalate without Hill sign‑off, even as Speaker Mike Johnson and John Thune refuse to recall Congress early.
The reactions split almost perfectly along the now‑familiar fracture lines. On the right, leadership Republicans and longtime Iran hawks like Lindsey Graham and Rick Crawford hail the joint U.S.–Israel operation as “necessary,” “long justified,” and proof of “peace through strength,” with Graham declaring “the end of the largest state sponsor of terrorism is upon us.” On the left and center, figures like Ruben Gallego, Mark Warner and Jim Himes call it “a war of choice with no strategic endgame” that risks dragging the U.S. into yet another open‑ended Middle East conflict, insisting America can back Iran’s democracy movement “without sending our troops to die.”
And because Washington never wastes a war, Republicans are already folding the Iran strikes into an unrelated fight over a partially shut‑down Department of Homeland Security, arguing that the new conflict proves Democrats must swallow their demands and fully fund DHS “at maximum readiness.” The pattern is as old as the War Powers Act: the president moves first, Congress scrambles for a briefing, leadership games out how to weaponize the crisis for domestic leverage — and only then do lawmakers remember they were supposed to be the ones deciding whether there would be a war in the first place.
#Iran#Trump#Congress#WarPowers#Netanyahu#LindseyGraham#Schumer#Gallego
📱American Оbserver - Stay up to date on all important events
🇺🇸