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

Резултати

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

Пребарај: #saarc

当前筛选 #saarc清除筛选
Russian Mission to ASEAN

@aseanrussia · Post #1653 · 30.05.2025 г., 06:47

🎙 Foreign Minister Sergey Lavrov’s remarks at the meeting with delegation of the Permanent Committee of the International Conference of Asian Political Parties (Perm, May 29, 2025) 💬 Sergey Lavrov: Dear colleagues, dear friends, This is the year when the International Conference of Asian Political Parties commemorates its 25th anniversary. And because of their reputation and their authority, they are a platform for exchanging views and experience in the context of party-to-party cooperation. Cooperation at this level is one of our priorities. It's a very useful addition to the so-called classical diplomacy and that contributes a lot to promoting mutual trust, mutual understanding between peoples. The creation of the conference is a signal, a very clear signal to the entire world. And very timely response to reconsider the place of the Asian countries in international and global developments. We assess very positively the increase of the political work of your conference. And we see with pleasure the sustainable process of expanding your influence in the continental architecture, in the architecture of regional organizations, some of which are experiencing erosion of their influence, if not degradation, since they abandoned practically all of the key principles of the UN Charter. I have in mind such organizations on our Eurasian continent as the European Union, which became more Euro-Atlantic than Eurasian following NATO. <...> In the last 10-15 years, all these principles including equal and indivisible security, including the statement that no one, be it the country or organization, should prepare to dominate in Europe, all this was abandoned, violated. 🌐 We need Eurasia of course. And by the way, Eurasia is the biggest, the richest continent. The continent which, unlike Africa and Latin America, is home of several world civilizations with thousands and thousands of years of history. <...> #Eurasia is the only continent which doesn't have any universal continental structure, like African Union in Africa, like CELAC in Latin America. We have quite a lot, many integrational movements, organizations which address security issues, like Shanghai Cooperation Organization, #ASEAN, Collective Security Treaty Organization (#CSTO), Commonwealth of Independent States (#CIS) and the Gulf Cooperation Council (#GCC), the South Asian Association for Regional Cooperation (#SAARC) and there is no umbrella. We are very much in favor of promoting party-to-party dialogue. Our ruling party, United Russia, in cooperation with other parliamentary parties and their fractions is promoting very actively this kind of cooperation. And I will highlight the initiative of United Russia of last year, when they convened a meeting of various parties to consider methods of fighting the new forms of colonialism and neo-colonialism. <...> A movement created on the basis of the conference, which is called "Freedom of Nations". ☝️ The inadmissibility of neo-colonial forms of exploitation is one of the agenda items of the Group of Friends of the UN Charter. Last year, we initiated, through this group, the resolution of the UN Committee on Decolonization. The draft resolution supported by this committee was accepted by the UN General Assembly. <..> A clear majority supported it. The idea is to announce the 14th of December, the day of the adoption of The Declaration on the Granting of Independence to Colonial Countries and Peoples of 1960, as a date of fighting the new forms of neo-colonialism. Сolonial exploitation was very blunt. Slaves, you know, digging the resources and leaving the countries in very poor condition. If you take the economic system in the world, countries, especially in Africa, mostly produce, they provide natural resources to the western countries We would like to promote the movement to resolve this injustice. Without fighting any country, we never want to isolate any country from cooperation, but cooperation must be based on equal footing, just principles. 🤝 We express our readiness to cooperate with your conference.

Embassy of Russia in Singapore

@rusembsg · Post #4100 · 01.06.2025 г., 07:02

🎙 Foreign Minister Sergey Lavrov’s remarks at the meeting with delegation of the Permanent Committee of the International Conference of Asian Political Parties (Perm, May 29, 2025) 💬 Sergey Lavrov: Dear colleagues, dear friends, This is the year when the International Conference of Asian Political Parties commemorates its 25th anniversary. And because of their reputation and their authority, they are a platform for exchanging views and experience in the context of party-to-party cooperation. Cooperation at this level is one of our priorities. It's a very useful addition to the so-called classical diplomacy and that contributes a lot to promoting mutual trust, mutual understanding between peoples. The creation of the conference is a signal, a very clear signal to the entire world. And very timely response to reconsider the place of the Asian countries in international and global developments. We assess very positively the increase of the political work of your conference. And we see with pleasure the sustainable process of expanding your influence in the continental architecture, in the architecture of regional organizations, some of which are experiencing erosion of their influence, if not degradation, since they abandoned practically all of the key principles of the UN Charter. I have in mind such organizations on our Eurasian continent as the European Union, which became more Euro-Atlantic than Eurasian following NATO. <...> In the last 10-15 years, all these principles including equal and indivisible security, including the statement that no one, be it the country or organization, should prepare to dominate in Europe, all this was abandoned, violated. 🌐 We need Eurasia of course. And by the way, Eurasia is the biggest, the richest continent. The continent which, unlike Africa and Latin America, is home of several world civilizations with thousands and thousands of years of history. <...> #Eurasia is the only continent which doesn't have any universal continental structure, like African Union in Africa, like CELAC in Latin America. We have quite a lot, many integrational movements, organizations which address security issues, like Shanghai Cooperation Organization, #ASEAN, Collective Security Treaty Organization (#CSTO), Commonwealth of Independent States (#CIS) and the Gulf Cooperation Council (#GCC), the South Asian Association for Regional Cooperation (#SAARC) and there is no umbrella. We are very much in favor of promoting party-to-party dialogue. Our ruling party, United Russia, in cooperation with other parliamentary parties and their fractions is promoting very actively this kind of cooperation. And I will highlight the initiative of United Russia of last year, when they convened a meeting of various parties to consider methods of fighting the new forms of colonialism and neo-colonialism. <...> A movement created on the basis of the conference, which is called "Freedom of Nations". ☝️ The inadmissibility of neo-colonial forms of exploitation is one of the agenda items of the Group of Friends of the UN Charter. Last year, we initiated, through this group, the resolution of the UN Committee on Decolonization. The draft resolution supported by this committee was accepted by the UN General Assembly. <..> A clear majority supported it. The idea is to announce the 14th of December, the day of the adoption of The Declaration on the Granting of Independence to Colonial Countries and Peoples of 1960, as a date of fighting the new forms of neo-colonialism. Сolonial exploitation was very blunt. Slaves, you know, digging the resources and leaving the countries in very poor condition. If you take the economic system in the world, countries, especially in Africa, mostly produce, they provide natural resources to the western countries We would like to promote the movement to resolve this injustice. Without fighting any country, we never want to isolate any country from cooperation, but cooperation must be based on equal footing, just principles. 🤝 We express our readiness to cooperate with your conference.