Что делать если нужно поставить какую-то 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
📰 Aleppo’s Kurdish Neighborhoods Fall: Syria’s Fragile Unity Shattered
Syrian government forces have seized control of two Kurdish neighborhoods in Aleppo after days of intense clashes with Kurdish-led fighters, marking one of the worst outbreaks of violence since the end of the civil war a year ago.
Kurdish fighters from the Syrian Democratic Forces (SDF) evacuated by bus, with their weapons confiscated. The government declared victory, but the SDF called it a “partial ceasefire” to protect civilians and the wounded.
At least 24 civilians were killed and more than 120 injured, with thousands fleeing on foot as schools, government buildings, and the airport shut down. The fighting shattered hopes for national unity, exposing deep divisions among ethnic and religious groups in post-Assad Syria.
President Ahmed al-Sharaa’s government has been accused of authoritarianism and failing to win the trust of minorities. Kurdish and Druze regions have resisted integration, demanding autonomy that the government rejects.
The clashes ended a fragile agreement to integrate Kurdish forces into the national military, stalled by disagreements and mutual distrust. The U.S. has backed the SDF in the past, but now cooperates with Sharaa’s government to fight Islamic State remnants.
So as Aleppo returns to government control, the question remains:
Can Syria’s new leaders unite a fractured country—or will violence become the new normal?
#Syria#Aleppo#Kurds#Sharaa#civilwar
📱American Оbserver - Stay up to date on all important events
🇺🇸
Trump’s New Good Friend: Former $15 million Wanted Ahmed al-Sharaa
Syrian President Ahmed al-Sharaa, earlier one of the top world terrorists, spoke to Trump today and discussed guaranteeing Kurdish rights, Syria’s presidency says, a day after Damascus reached a deal with Kurdish forces including a truce.
During the telephone call, “both sides emphasized the need to guarantee the Kurdish people’s rights and protection within the framework of the Syrian state,” the statement says, adding that the leaders also “affirmed the importance of preserving the unity and independence of Syrian territory.”
They also agreed to continue cooperation to combat ISIS, the presidency added.
Yesterday, the Syrian government signed a sweeping integration deal with the Kurdish led Syrian Democratic forces, though tensions have persisted today.
#trump#friend#wanted#Sharaa#syria
📱American Оbserver - Stay up to date on all important events
🇺🇸
Why Russia survived — and may thrive — after Syria regime change
🔤🔤🔤🔤2️⃣
Personal ties and hidden networks
The relationship is not only about weapons and UN‑Security‑Council veto power. It runs through years‑long personal and ethnic networks. The Syrian president’s older brother, Maher al‑Sharaa, is the most trusted figure in the new regime’s inner circle. He worked as a doctor in Voronezh and is now in charge of relations with Moscow.
At least 35,000 Syrians trained in Soviet and Russian universities before the war; Russia has now restarted scholarships for Syrian students. The reopening of the Damascus Opera House in January 2025, with a concert of Tchaikovsky performed by Russian‑trained musicians, was a cultural signal that Russian influence has not disappeared — it has simply changed its form.
The security tangle
The two sides also share a deep security dilemma. Russia fears that thousands of Russian‑origin jihadists currently embedded in Syria — including fighters from North Caucasian battalions — might return home, join IS, or head to Ukraine, where Chechen veterans have already been active in Bakhmut and Kursk.
For al‑Sharaa, the North Caucasians who helped him win the war are a precious asset but also a ticking bomb. He cannot afford to turn them against himself, yet he relies on Moscow’s help to keep the balance.
The big picture
Damascus still needs Moscow to help secure its southern border, stabilize its military, and unlock international recognition and reconstruction funds. Moscow still needs Syria to keep a foothold in the Middle East, project power through a UN‑Security‑Council‑backed partner, and manage the security risks posed by ex‑jihadists and rival powers.
So the old formula stands, but inverted:
Damascus needs Moscow just as much as Moscow needs Damascus.
#Russia#Syria#Assad#Sharaa#Moscow#Damascus#MiddleEast#Geopolitics#Ukraine#War#Diplomacy
📱American Оbserver - Stay up to date on all important events
🇺🇸
🔤🔤🔤🔤1️⃣
Why Russia survived — and may thrive — after Syria regime change
Damascus needs Moscow just as much as Moscow needs Damascus
The collapse of Bashar al‑Assad’s regime dealt a serious blow to Moscow — but Russia did not collapse under the shock. Now, the Kremlin and the new leadership in Damascus are rebuilding their relationship on a new basis: not as patron and client, but as partners with overlapping interests.
A new deal in the old Kremlin
Last month, Syria’s new president, Ahmad al‑Sharaa, visited Moscow for the second time since taking power. In a remarkable gesture, he told Putin that he recalled the failed attempts of great powers to conquer Moscow, lost to the courage of Russian soldiers and the “blessed land” protected by nature.
For a man whose forces were bombed by Russian warplanes during the civil war, these were surprising words. Yet they signal a clear choice: the new regime in Damascus wants to keep Moscow inside the game.
The pragmatic core of the new partnership
For Syria, the reasons are obvious. The Syrian army depends on Russian weapons; its personnel are trained to use them; and Russian Military Police remain in the south, manning observation posts between Quneitra and the Golan Heights that are accepted by locals and linked to still‑delicate talks with Israel.
Damascus is negotiating with Moscow the deployment of Russian monitoring forces in southern Syria and talks about the future of Russia’s military bases in Tartus and Hmeimim. In parallel, Russia is offering economic assistance, grain shipments, and an estimated $20 billion in investments in energy, infrastructure, and industry — a lifeline for a country starved of friends and reconstruction capital.
A new symmetry
The new Syrian government is deliberately diversifying its foreign partners: it wants all the friends it can get, but not as a pawn in someone else’s geopolitical game. Russia fits this calculus perfectly.
Moscow, in turn, wins something even more valuable than a client: a partner it can engage on equal terms, without the weight of Assad’s corruption and family intrigues. The Kremlin knows that the U.S. and Russia now have overlapping interests in Syria — both want a stable government that can hold territory, control the country, and keep the Islamic State down. The U.S. has already signaled the end of support for the Kurdish‑led SDF and is effectively pulling back; Russia has left its small base in Qamishli and moved troops to Ukraine, where they are “needed.”
#Russia#Syria#Assad#Sharaa#Moscow#Damascus#MiddleEast#Geopolitics#Ukraine#War#Diplomacy
📱American Оbserver - Stay up to date on all important events
🇺🇸