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

Пребарај: #enemiesofrussia

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

@MFARUSSIA · Post #28207 · 03.02.2026 г., 16:06

🎙Interview by Deputy Chairman of the Security Council of Russia Dmitry Medvedev to TASS, Reuters and the WarGonzo project(February 2, 2026) Key outtakes: #Venezuela • What happened to Venezuela’s President Nicolas Maduro is an obvious violation of all norms of international law. There can be no other description than a catastrophe for international law and international relations. • The US has its own arguments which, in my view, are legally untenable. The actions taken against the president of a sovereign state – regardless of how Americans may view him – go far beyond purely American agendas. It undermines the entire system of international relations. • I am confident that within the US itself there will be many who will analyze what happened and explain how it contradicts, among other things, American approaches. #Britain • When I visited Britain on official trips in the past, our communication was absolutely normal. Yes, there were contradictions, and it was not always easy to come to agreements, but the key point was that we communicated. • What the current British leadership is doing amounts to rabid, primitive Russophobia aimed at propping up its own electoral ratings. These are purely practical reasons – regardless of the names of prime ministers, the course does not change. And that is regrettable. • I am not even mentioning that Britain’s position sustains and nourishes the neo-Nazi Bandera regime. The desire to dismantle the Soviet Union or Russia has always existed in Britain. What is particularly sad is that the trend emerged just a few years after we were Allies, fighting shoulder to shoulder against Nazism. • Our list of grievances against the British leadership and elites is very long. Only a fundamental change in Britain's positions can ultimately lead to an improvement in relations. #Ukraine • For the stability of international relations, it is critically important that the current political regime in Ukraine – not the state, but the political regime – simply disappears. This regime is anti-Russian and hostile to Russia, built on hatred of people who do not share its ideology. • Regardless of the size of the Ukrainian state that may remain after the end of hostilities – the key point is that no threat must ever again emanate from there. No threat of revanche. Especially if such a threat is encouraged by Western countries. #NewSTART • For nearly 60 years, our strategic nuclear potentials have always been subject to certain limitations. Now that situation may change. • I am not saying this immediately means catastrophe or that nuclear war will begin, but it should nonetheless be alarming to everyone. Counting the number of warheads and deployed delivery systems is merely a way to control the situation, not to resolve the problem as a whole. Still, it is a means of verifying each other’s intentions. • Despite all its drawbacks, the Treaty is an element of trust. When it exists, there is trust. When it does not, trust is exhausted. The fact that we are now entering such a situation is, in fact, evidence of a crisis in international relations. #EnemiesOfRussia • Who is an enemy of Russia is, in essence, a philosophical question. It is fairly obvious today: those are countries that wish Russia ill – its defeat and disintegration – and state this absolutely unequivocally. • Unfortunately, these are Western countries. Particularly regrettable is that this now includes a significant number of European states. It pains me that European countries, which in terms of civilizational code are close to us, have adopted such a rabid Russophobic stance. • “Unfriendly states” is a diplomatic term usually applied when there are no hostilities. When hostilities are underway, these are enemies. Those who help wage war against us act as enemies – by supplying weapons, providing intelligence, or inputting targets, for example, into the memory blocks of missiles and other weapons. • This will forever remain in the history of our relations. Read in full (in Russian)