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 слични објави

Пребарај: #russialas

当前筛选 #russialas清除筛选
Russian MFA 🇷🇺

@MFARUSSIA · Post #28436 · 18.02.2026 г., 19:29

🎙 Russia's Foreign Minister Sergey Lavrov’sinterview with Al Arabiya television channel(Moscow, February 17, 2026) Key talking points: #TheArabWorld • We enjoy solid relationships with all Arab countries and their organisations. These include the League of Arab States (LAS), with which we have held about half a dozen ministerial meetings. We also plan to hold the Russia-LAS summit. We also maintain a close relationship with the Gulf Cooperation Council (GCC), which has been maintained by annual events at the level of foreign ministers. #SaudiArabia • Saudi Arabia is the leader of the Arab world, a country of two Holiest sites in Islam, and the author of the Arab Peace Initiative to settle the most complicated and enduring crisis, the Palestinian issue. • Our country regards Saudi Arabia as its strategic partner in the region. We believe that this view is shared by our Saudi colleagues. We are very pleased with our cooperation. • We are developing humanitarian, cultural, educational and sports ties. <...> A few days ago, I had a conversation with my friend, Foreign Minister Faisal bin Farhan Al Saud. One of the issues we discussed concerned the preparation of Intervision International Music Contest, which reflects the striving of Russia and Saudi Arabia to promote traditional values. • We enjoy solid relationships with all Arab countries and their organisations. These include the #LAS, with which we have held about half a dozen ministerial meetings. We also plan to hold the #RussiaLAS summit. We also maintain a close relationship with #GCC. #Iran • Regrettably, Israel and the US went ahead with the strikes [against Iran], creating physical risks and undermining the authority of the #IAEA and the #NPT. The IAEA has exerted unprecedented control, especially in the past years, after the signing of the #JCPOA. Iran was never found violating the Non-Proliferation Treaty or its agreement on guarantees with the IAEA. All risks and political tensions emerged after the US withdrew from the JCPOA in 2018. #Syria • Mutual respect and mutual benefit – these are the principles that have underpinned our relations with Syria from the very beginning, since its establishment. We hold these relations in high regard. • We firmly believe that a multiethnic, multi-confessional state such as Syria must restore its unity, territorial integrity, and sovereignty as swiftly as possible. In this endeavour, we will continue to – and indeed already do – assist Damascus and its new leadership. • As for our military facilities, discussions are ongoing. Let me reiterate: the Syrians are keen for our presence to endure. #Palestine • We should not overlook the fact that the situation in the West Bank is becoming increasingly tense and volatile as a result of Israeli actions, including the recent issuance of directives regulating land acquisition and urban development procedures. Until recently, such matters were coordinated with the Palestinian National Authority. Now, however, unilateral decisions are being taken, and analysis of their likely consequences suggests that little may remain of the territories currently administered by the Palestinian National Authority. Now, however, unilateral decisions are being taken, and analysis of their likely consequences suggests that little may remain of the territories currently administered by the Palestinian National Authority. #UkrainianCrisis • Europe hysterically demands that Russia start talks and that all sides agree that Europe must be part of these talks. <...> Europe has revealed its Nazi essence, which we thought was destroyed with the Hitler’s defeat in WWII. It has turned out to be extremely tenacious. I don’t see what role Europe could play. • We greatly value the stance taken by the Trump administration and personally by the President of the US. We are closely observing Europe’s attempts to dissuade the current Washington administration from its principled stance, as discussed and agreed in Anchorage, Alaska. We remain fully committed to those understandings. Read in full