Что делать если нужно поставить какую-то 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
News: #Ethiopia rolls out national #EV charging network in E-Mobility push
Ethiopia’s state-owned Ethiopian Electric Utility (#EEU) is rolling out a national network of electric vehicle charging stations as part of a government strategy to accelerate the shift to low-emission transport.
According to EEU communications director Anwar Abrar, the program will be implemented in two phases.
The first phase involves installing 40 stations, most of them in the capital, #Addis_Abeba. Three are already operational. Another 32 are expected to become operational in the city, with eight more planned in surrounding areas in the coming months.
According to the Ministry of Transport, the country’s electric vehicle fleet has grown from zero to more than 140,000 units in three to four years. To support that growth, 2,300 charging points are planned nationwide, including about 1,176 in Addis Abeba......
https://www.facebook.com/AddisstandardEng/posts/pfbid02Q2x7SDdLdnaWLSr82ypwEUsMkCb59DbTBLBQKZfzuGqwe4Dw8FDLygzBfJNU3DHml
🗓 On September 18, the deputy head of the Russian Mission to ASEAN Mr. Andrey Yudin🇷🇺 took part in the 2nd ”Conference of the High Contracting Parties to the Treaty of Amity and Cooperation in Southeast Asia (#TAC)” held at the ASEAN Headquarters in Jakarta 🇮🇩.
Key points of the intervention:
🔹️On September 3, we celebrated the 80th Anniversary of the end of the World War II – the bloodiest conflict in the history of mankind that affected over 80 percent of the world’s population, including the Asia-Pacific region.
🔹️The defeat of Nazism and militarism created the conditions for decolonisation process in Asia and the subsequent formation of the modern regional security and cooperation architecture with ASEAN in its core. The TAC is one of the key elements of this architecture.
🔹️The TAC has served for almost a half-century as the key code of conduct in governing inter-state relations in the region and as a foundation for maintaining regional peace and stability.
🔹️The aspirations and spirit of the TAC resonate with the fundamental pillars of the foreign policy of Russia 🇷🇺. Both ASEAN and Russia remain committed to the values of multilateralism, equitable inter-state cooperation and peaceful sustainable development of the Asia-Pacific region.
🔹️Further development of cross platform ties in line with article 6 of the TAC between ASEAN, the Shanghai Cooperation Organisation (#SCO) and the Eurasian Economic Union (#EEU), which share the same principles and goals, will be of great mutual benefit and help to create a transregional space of peaceful co-development.
🗓On April 26, Saint Petersburg 🇷🇺 hosted the 20th ASEAN-Russia Senior Officials' Meeting (#ARSOM).
🔹️The meeting was co-chaired by the Deputy Foreign Minister of the Russian Federation H.E. Mr. AndreyRudenko🇷🇺 and Secretary of State of the Ministry of Foreign Affairs and International Cooperation of the Kingdom of Cambodia H.E. Mr. Kung Phoak🇰🇭.
🔹 Participants discussed ways and means of further promoting the ASEAN-Russia Strategic Partnership in political, economic and humanitarian spheres. They agreed to undertake steps to deepen practical cooperation in such areas as science and technology, energy security, education, people-to-people ties and digitalization.
🔹The meeting reiterated shared intention to jointly address challenges and threats, strengthen ASEAN-led regional security architecture in Asia-Pacific. Issues of promoting cross-platform links between #ASEAN, #EEU and #SCO were also on the agenda.
🔹️On the sidelines of the ARSOM H.E. Mr. Andrey Rudenko held bilateral consultations with the heads of delegations of Cambodia 🇰🇭, Indonesia 🇮🇩, Lao PDR 🇱🇦 and Vietnam 🇻🇳.
#ASEANRussia#RussiaASEAN#ARSOM
🗓On February 19, Jakarta 🇮🇩 hosted the 21st ASEAN-Russia Senior Officials' Meeting (#ARSOM).
🔹️The meeting was co-chaired by the Deputy Foreign Minister of the Russian Federation H.E. Mr. Andrey Rudenko 🇷🇺 and Permanent Secretary of the Ministry of Foreign Affairs of the Republic of the Union of Myanmar H.E. Mr. Aung Kyaw Moe🇲🇲.
🔹 Participants discussed ways and means of further promoting the ASEAN-Russia Strategic Partnership with an emphasis on such priority areas as science and technology, digitalization, energy, and the development of smart cities.
🔹️Specific steps were outlined to further diversify practical cooperation. Particular attention was paid to the prospects for launching new joint mechanisms and initiatives, in particular, in the field of youth ties and biological security. Both sides expressed their commitment to further enhancing the ASEAN-Russia Strategic Partnership under the forthcoming Comprehensive Plan of Action for 2026-2030.
🔹The meeting reiterated shared intention to jointly address challenges and threats, strengthen ASEAN-led regional security architecture in Asia-Pacific. Issues of promoting cross-platform links between #ASEAN, #EEU and #SCO were also on the agenda.
🔹️On the sidelines of the ARSOM an Exhibition "ASEAN-Russia: prospects of cooperation in civilian nuclear energy and technologies" was opened at the ASEAN Headquarters.
#ASEANRussia#RussiaASEAN#ARSOM
🗓On April 26, Saint Petersburg 🇷🇺 hosted the 20th ASEAN-Russia Senior Officials' Meeting (#ARSOM).
🔹️The meeting was co-chaired by the Deputy Foreign Minister of the Russian Federation H.E. Mr. AndreyRudenko🇷🇺 and Secretary of State of the Ministry of Foreign Affairs and International Cooperation of the Kingdom of Cambodia H.E. Mr. Kung Phoak🇰🇭.
🔹 Participants discussed ways and means of further promoting the ASEAN-Russia Strategic Partnership in political, economic and humanitarian spheres. They agreed to undertake steps to deepen practical cooperation in such areas as science and technology, energy security, education, people-to-people ties and digitalization.
🔹The meeting reiterated shared intention to jointly address challenges and threats, strengthen ASEAN-led regional security architecture in Asia-Pacific. Issues of promoting cross-platform links between #ASEAN, #EEU and #SCO were also on the agenda.
🔹️On the sidelines of the ARSOM H.E. Mr. Andrey Rudenko held bilateral consultations with the heads of delegations of Cambodia 🇰🇭, Indonesia 🇮🇩, Lao PDR 🇱🇦 and Vietnam 🇻🇳.
#ASEANRussia#RussiaASEAN#ARSOM
🗓On 28 April 2023 Siem Reap, Cambodia 🇰🇭 hosted the 19th ASEAN-Russia Senior Officials' Meeting (#ARSOM). Russian delegation was headed by the Deputy Foreign Minister H.E. Mr. Andrey Rudenko.
🔹 Participants discussed preparations for the ASEAN-Russia Foreign Ministers' Meeting to be held in July. They agreed to undertake a number of specific steps to implement and further promote the ASEAN-Russia Strategic Partnership which celebrates its 5th Anniversary this year and exchanged views on ways to further deepen cooperation in political, economic and humanitarian spheres.
🔹Delegates agreed to increase interaction on food and energy security, digitalization, finance, education, including by creating new cooperation mechanisms.
🔹The Meeting reiterated shared intention to jointly address challenges and threats, strengthen ASEAN-led regional security architecture in Asia-Pacific. Issues of promoting cross-platform links between #ASEAN, #EEU and #SCO were also on the agenda.
#ASEANRussia#RussiaASEAN#ARSOM
🇷🇺🇧🇾 On June 9-10, Foreign Minister Sergey Lavrovheld talks with Foreign Minister of the Republic of Belarus Maxim Ryzhenkov, who was on his first official visit in Moscow.
The talks were held in a traditionally trust-based and truly comradely atmosphere. The Ministers discussed a wide range of key issues of Russia-Belarus strategic partnership and alliance. They focused on diplomatic support for the integration process in the Union State. They voiced coinciding or quite similar positions, while considering current international and regional issues, including the resolution of the Ukraine crisis.
The Sides exchanged opinions regarding their future collaboration to forge a Greater Eurasian Partnership and new Eurasian security architecture. Following the meeting, Sergey Lavrov and Maxim Ryzhenkov signed a joint address to the foreign ministers of Eurasian states on drafting the Charter of Eurasian Diversity and Multipolarity in the 21st Century. The Ministers reviewed, in great detail, issues of future integration within the framework of the Collective Security Treaty Organisation (#CSTO), the Eurasian Economic Union (#EEU), the Commonwealth of Independent States (#CIS) and the Shanghai Cooperation Organisation (#SCO), as well as mutual collaboration at the United Nations Organisation and the Organisation for Security and Cooperation in Europe (#OSCE).
Addressing a joint news conference, the Foreign Ministers of Russia and Belarus discussed, in great detail, the agreements reached by them.
#RussiaBelarus#UnionState