Что делать если нужно поставить какую-то 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
📝The Honorary Consul of South Africa in Yekaterinburg, Sergey Mazurkevich, signed letters of appreciation, which were personally delivered to colleagues by the staff of the Honorary Consul’s office.
🗓 In 2024–2025, South African English teacher Samora “Sam” Buzwe Poswa actively participated in events dedicated to South Africa.
🇷🇺🤝🇿🇦Key initiatives implemented within this cooperation include:
— 🇿🇦🎓Sam conducted a series of presentations about South Africa for English learners:
• At local language schools:
🔗https://t.me/sarconsulurals/1438
• At Gymnasium No. 13, Yekaterinburg (together with the Honorary Consul’s office)
🔗https://t.me/sarconsulurals/1489
• At Ural State Forestry Engineering University (USFEU)
🔗https://t.me/sarconsulurals/1575
• At the Institute of International Relations (IIR)
🔗https://t.me/sarconsulurals/1893
• At Gymnasium No. 212
🔗https://t.me/sarconsulurals/2682
— 🇿🇦🗣Participated as an English-language speaker at the interpreting contest for law students at Ural State Law University (USLU)
🔗https://t.me/sarconsulurals/2080
— Contributed to the development of the Honorary Consul’s Telegram channel by providing useful comments and photos.
🤝 Dear Samora Buzwe Poswa,
I would like to express my sincere appreciation for your professionalism, active cooperation, and contribution to the development of Russia–South Africa relations in 2024–2025.
With respect and looking forward to continuing our cooperation,
Honorary Consul
of the Republic of South Africa
in Yekaterinburg
Sergey Mazurkevich
#SouthAfrica#Yekaterinburg#USLU#Diplomacy#HonoraryConsul#Mazurkevich#InternationalCooperation
📝The Honorary Consul of the Republic of South Africa in Yekaterinburg, Mr. Sergey Mazurkevich, signed letters of appreciation, which were personally handed to colleagues by the staff of the Honorary Consul's office.
🗓 In 2024–2025, Dr. Yelena Kagan, Associate Professor at the Department of Russian, Foreign Languages, and Speech Culture at Ural State Law University (USLU), invited the Office of the Honorary Consul of South Africa on multiple occasions to deliver presentations and also organized or co-organized other events.
🇷🇺🤝🇿🇦 Key initiatives implemented within this cooperation include:
— 🇿🇦 Conference Language. Speech. Personality
At Dr. Kagan's invitation, the Honorary Consul’s Office staff delivered a talk on the language situation in South Africa.
🔗https://t.me/sarconsulurals/1580
— 🇿🇦🎓Beyond the Visible: Light and Shadow of AI in Translation
Dr. Kagan organized a roundtable where the office staff shared their experience using artificial intelligence to manage the Honorary Consul’s social media with faculty, graduate students, and undergraduates.
🔗https://t.me/sarconsulurals/1933
— 🇿🇦South Africa: From Apartheid to the Post-Apartheid Constitution, and the Role of Honorary Consuls
At Dr. Kagan’s invitation, the Honorary Consul’s Office conducted a presentation for law students.
🔗https://t.me/sarconsulurals/2837
— ⚖️🎓 Crime and Punishment: Interpreting Contest
Dr. Kagan co-organizes annual interpreting contests for law students. Those vibrant contests featured English-language guests from South Africa, Samora Poswa and Luyanda Simamane. 🇿🇦
🔗https://t.me/sarconsulurals/990
— 📘🌍 Guidebook for African university students
Dr.Kagan is part of the working group preparing a multilingual guidebook that provides guidance on the rights and responsibilities of international students in Russia and helps them avoid mistakes and administrative penalties.
🔗https://t.me/sarconsulurals/2616
🤝 Dear Dr. Kagan,
I would like to express my sincere appreciation for your professionalism, active cooperation, and contribution to the development of Russia–South Africa relations in 2024–2025.
With respect and looking forward to continuing our cooperation,
Honorary Consul
of the Republic of South Africa
in Yekaterinburg
Sergey Mazurkevich
#SouthAfrica#Yekaterinburg#USLU#Diplomacy#HonoraryConsul#Mazurkevich#InternationalCooperation
📘🌍 The third online meeting of the working group on the preparation of a brochure for African students at Yekaterinburg universities has been held.
During the meeting, the Office of the Honorary Consul of South Africa, together with faculty members of Ural State Law University (USLU), discussed the structure of the brochure and the work plan for 2026.
👩🏫👨🏫 The USLU project team includes:
⚖️Dr. Svetlana Kuznetsova, PhD (Law)
📖Dr. Natalia Yushkova, PhD (Philology)
📖Dr. Yelena Kagan, PhD (Philology)
📖 Vitaly Yankovsky, Analyst, Department of International Cooperation
#SouthAfrica#Russia#Yekaterinburg#Africa#Students#Education#InterculturalDialogue#USLU
📘🌍A Guide for African Students — the Project Continues!
The Office of the Honorary Consul of South Africa and faculty members of Ural State Law University (USLU) held their second online meeting to develop a guide for African students studying at Yekaterinburg universities.
So far, all major universities in the city have shared their materials designed for international students. We are now systematizing and integrating this information.
👩🎓🇷🇺 The guide will explain the rights and responsibilities of international students in Russia and help them avoid mistakes and administrative issues.
🌐 It will be published in Russian, English, French, Portuguese, and Arabic.
From USLU, the project team includes:
⚖️ PhD (Law) Dr. Svetlana Kuznetsova
📖 PhD (Philology) Dr. Natalia Yushkova
📖 PhD (Philology) Dr. Yelena Kagan
📖Vitaly Yankovsky, Analyst at the Department of International Cooperation
#SouthAfrica#Russia#Yekaterinburg#Africa#Students#Education#InterculturalDialogue#USLU
📘🌍 A Guide for African Students — Project Launched!
The Office of the Honorary Consul of South Africa, together with faculty from Ural State Law University (UrSLU), has launched a project to create a practical guide for African students studying at Yekaterinburg-based universities.
👩🎓🇷🇺 The guide will explain students’ rights and responsibilities in Russia and help them avoid mistakes and administrative penalties.
🌐 It will be available in Russian, English, French, Portuguese, and Arabic.
From USLU, the project team includes:
⚖️ Dr. Svetlana Kuznetsova (Law)
📖 Dr. Natalia Yushkova (Philology)
📖 Dr. Yelena Kagan (Philology)
#SouthAfrica#Russia#Yekaterinburg#Africa#Students#Education#InterculturalDialogue#USLU
Сотрудники офиса Почётного консула ЮАР приняли участие в работе круглого стола «За гранью видимого: свет и тень ИИ в переводе» в Уральском государственном юридическом университете (УрГЮУ).🎓
Мы поделились с преподавателями, аспирантами и студентами опытом использования искусственного интеллекта в ведении соцсетей офиса Почётного консула ЮАР в Екатеринбурге. 🇿🇦
#ЮАР#Екатеринбург#ИскусственныйИнтеллект#ИИ#УрГЮУ
_______________
Staff of the Honorary Consul of South Africa took part in the roundtable discussion Beyond the Visible: Light and Shadow of AI in Translation at the Ural State Law University (USLU). 🎓
We shared our experience with faculty, postgraduates, and students on using artificial intelligence to manage the social media accounts of the Honorary Consul’s office in Yekaterinburg. 🇿🇦
#SouthAfrica#Yekaterinburg#ArtificialIntelligence#AI#USLU
⚖️Crime and Punishment: Ural State Law University (USLU) held a vibrant interpreter contest featuring Samora "Sam" Poswa — a South African English teacher living and working in Yekaterinburg. 🇿🇦🇷🇺
🏛 Participants discussed legal systems from various countries and periods in history.
🗣 Professor Svetlana Remizova spoke in Russian, Sam in English, while law students delivered consecutive interpretation.
The event was supported by the Office of the Honorary Consul of South Africa in Yekaterinburg. 🇿🇦🤝🇷🇺
🏆 The Best Communicator award went to a talented student, who received a Russian-language edition of Jim Is Tired of Jo’burg — a book by former South African Ambassador to Russia, Mzuvukile Maqetuka, translated in 2024 in Yekaterinburg.
📖 The Office also shared the story behind the translation project, launched by Honorary Consul Sergey Mazurkevich.
#USLU#Yekaterinburg#LawSchool#Education#Interpretation#Interpreters#Translation#SouthAfrica#Mazurkevich#Law#LegalEnglish#AfricaInRussia