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

Резултати

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

Пребарај: #guelleh

当前筛选 #guelleh清除筛选
Addis Standard

@addisstandardeng · Post #22003 · 11.04.2026 г., 06:52

News: #Djibouti President Ismaïl Omar Guelleh re-elected for sixth term after victory in latest vote Djibouti's President Ismail Omar #Guelleh on Saturday claimed a landslide victory in an election that secured his sixth straight term at the helm of the strategically placed Horn of Africa nation. Guelleh won Friday's presidential election with 97.8 percent of the vote, according to official results. He beat his sole opponent Mohamed Farah Samatar, little known by the general public, who secured just 2.2 percent of the vote, according to interior ministry figures. "Re-elected", the 78-year-old declared in a social media post ahead of the official results, after early results gave him a huge lead. Guelleh has ruled the tiny nation of one million people for 27 years with an iron grip. He has made his name leveraging Djibouti's key location to turn it into an international military ....... https://www.facebook.com/AddisstandardEng/posts/pfbid02cuqZZnyp5EcLHnw4yaoE6G6tQWm3xJDZVgu5ERGMHCrJDoKr8gDmbM5xPnAebEG4l

Addis Standard

@addisstandardeng · Post #21039 · 11.01.2026 г., 14:24

News: #PM_Abiy visits #Djibouti, tours Doraleh Port weeks after #Egypt signs port and energy deals Prime Minister Abiy Ahmed arrived in Djibouti today for talks with President Ismaïl Omar #Guelleh and a tour of the Port of #Doraleh, weeks after Egypt signed cooperation agreements with Djibouti on port development, logistics, and renewable energy. In a statement shared following his arrival, Abiy said discussions with President Guelleh focused on “geopolitical dynamics, regional peace and security, and strengthening bilateral cooperation,” particularly in trade, logistics, and development, reaffirming a shared commitment to stability, economic integration, and mutual prosperity. The Prime Minister also toured the Doraleh port complex, Ethiopia’s principal maritime gateway. The visit comes amid heightened regional attention to Red Sea logistics. On 27 December, 2025, Egypt and Djibouti signed three cooperation agreements during an official visit by Kamel.... Read more: https://addisstandard.com/?p=54486

Addis Standard

@addisstandardeng · Post #21688 · 12.03.2026 г., 08:44

News: Leaders of #Djibouti, #Ethiopia, #Somalia hold tripartite talks on regional peace, security Ismaïl Omar #Guelleh hosted a tripartite meeting with #Abiy_Ahmed Ali and #Hassan_Sheikh Mohamud in Djibouti on Wednesday, with discussions focusing on peace and security in the Horn of Africa and broader regional cooperation. According to a statement from the Djiboutian presidency, the leaders met at the private residence of President Guelleh in Haramous during an Iftar dinner, where they held consultations aimed at strengthening coordination and collective responses to shared regional challenges. The discussions covered peace and security in the region, the progress of economic integration among countries in the subregion, and issues of common interest affecting the three nations. The leaders also exchanged views on the prevailing political and security situation in the Horn of Africa. The meeting further addressed the ongoing conflict in the Middle East ..... Read more: https://addisstandard.com/?p=55774

Addis Standard

@addisstandardeng · Post #21606 · 04.03.2026 г., 09:55

Four children killed in #Djibouti 'drone strike' explosion: official, NGO Four children were killed in southern Djibouti in an explosion, authorities said late Tuesday, with a human rights group saying it was a drone strike. The children died in an explosion in the #Dhikil region in #Afar, public prosecutor Hassan Mohamed Hassan said in a statement, calling it a tragic event. Afar's community feels marginalised by President Ismail Omar #Guelleh, a member of the majority Issa community, who has ruled the country with an iron fist since 1999. "Two children, aged six and seven (a girl and a boy), were killed at the scene, and on Tuesday two others succumbed to their injuries due to a lack of evacuation and medical care," the Djiboutian League for Human Rights (#LDDH) said in a press release. The LDDH said the children were tending livestock when the incident took place and that.... https://web.facebook.com/AddisstandardEng/posts/pfbid037tZUcL1PYTnwEdFMBf2aLFw9oqiCJtFEgDvXKgddZQQa2CBTDdSTm1p2pcNcTkj9l

Addis Standard

@addisstandardeng · Post #21562 · 28.02.2026 г., 10:58

#Djibouti leader wary of #Israel’s presence in #Somaliland Djibouti President Ismail Omar #Guelleh on Friday warned that the establishment of an Israeli military base in the strategic port city of #Berbera in Somaliland will pose a direct threat to regional stability. Speaking to a local media, Guelleh accused Israel of exploiting Somaliland’s decades-long quest for statehood to secure a foothold in the Horn of Africa. He expressed deep concern that the authorities in #Hargeisa might agree to any geopolitical concession in exchange for formal recognition. The veteran leader also leveled uncharacteristically blunt criticism at the United Arab Emirates, describing the Gulf nation as Israel’s primary “gateway” into the region. Guelleh pointed out that the #UAE is driving strategic shifts in the Horn of Africa and the #Red_Sea that exacerbate existing conflicts. He further alleged.... https://web.facebook.com/AddisstandardEng/posts/pfbid02eCjUg8BmbcGMNdTaybhh1dcaRUKUG8Gt8batRZvmsGemat4LxFLfoWLCD8eVbcdUl