Что делать если нужно поставить какую-то 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
Dehumanization, structural violence and the collapse of citizenship : A sociological and social-psychological analysis of the situation of the Amhara population in Ethiopia። Read more.
https://borkena.com/2026/02/14/dehumanization-structural-violence-and-the-collapse-of-citizenship-a-sociological-and-social-psychological-analysis-of-the-situation-of-the-amhara-population-in-ethiopia/#Ethiopia#politics#Amhara#citizenship
🛂🇺🇸RECORD 6,700 AMERICANS RENOUNCE CITIZENSHIP
🔹 2025 sees highest exodus in US history as wealthy Americans flee to tax havens overseas 🏝️💰
🔹 Switzerland, Singapore, UAE top destinations with total wealth transfer of $2.3 trillion 📊✈️
🔹 IRS crackdown on overseas accounts drives surge alongside political polarization fears 🏛️⚖️
🔹 Immigration lawyers report 300% increase in consultation calls from high-net-worth clients 📞💸
When the rich start running, what does that say about where we're headed? 🤔💭
American Dream or American Nightmare? You decide 🇺🇸🔥
#USNews#Citizenship#Taxes#WealthFlight
@america
🇷🇺❤Today marks a monumental chapter in my journey, as I proudly announce that I've become a Russian citizen and participated in my very first election here.
This significant step is more than just a formal process; it symbolizes my deep connection and commitment to my new home, its people, and its future. As I stood in the polling station, casting my vote, I was overwhelmed with a sense of responsibility and belonging.
This act of civic engagement is a powerful reminder of the role we each play in shaping the course of our community and nation. It's a day filled with emotions - pride, hope, and anticipation for what lies ahead.
Joining my fellow citizens in this democratic process, I felt a strong bond of unity and shared purpose. Here's to embracing new beginnings, contributing to the collective future, and making every moment count in this beautiful journey.
#Citizenship#ElectionDay#NewChapter#RussianCitizen🇷🇺✨
Documentation News:
In Moscow, two men who failed to register for military service were stripped of their citizenship
This was reported on the Telegram channel by the official representative of the Russian Ministry of Internal Affairs Irina Volk.
Volk recalled that, in accordance with Russian law, every man with acquired citizenship must register for military service within two weeks. Violators face punishment.
Our advise to members:
1. Comply with local laws. Register for military service if you are of draft age and have acquired citizenship.
2. Similarly, if you are of draft age and have no plans to register for military service, then you should consider not applying for citizenship.
Like the popular saying goes, you can't eat your cake and have it.
https://t.me/nido_russia/1827
#laws#naturaliation#documentation#passport#citizenship
Source: Life(.ru)
The Chairman of the Investigative Committee of the Russian Federation, Alexander Bastrykin, stated that more than 30 thousand migrants who recently received Russian citizenship and did not register for military service were "caught" in the country, about 10 thousand of them were sent to the special operation zone.
Along with citizenship, according to him, they received "not only rights, but also a constitutional obligation to protect the country that accepted them."
“Comrades, digging trenches and creating fortifications requires really good working hands. Today they are joining the ranks of our rear units that are building these fortifications.” he said.
Migrants seeking citizenship must bear this in mind.
Subscribe: @nido_russia
https://t.me/nido_russia/1675
Sources: TASS, Yugopolis
#citizenship#naturalisation#naturalization#Russia#Ukriane#svo
📢 On July 1, 2024 , a law comes into force that provides for a 20% indexation of state fees. So from 1 July, state fees for a number of state services will increase:
🔸 Temporary residence permit: from 1600 to 1920 Rubles;
🔸 Residence permit: from 5000 to 6000 Rubles;
🔸 Russian citizenship: from 3500 to 4200 Rubles;
🔸 Registration at the place of residence: from 350 to 420 Rubles;
🔸 Visa renewal: from 1000 to 1200 Rubles;
🔸 Issuance of invitations to the Russian Federation: from 800 to 960 Rubles;
🔸 Work permit: from 3500 to 4200 Rubles;
🔸 Permit to hire foreign workers: from 10,000 to 12,000 Rubles;
🔸 Travel passport; from 5000 to 6000 Rubles;
🔸 Travel passport up to 14 years old: from 2500 to 3000 Rubles.
❗️ Make all relevant applications before 1 July, to avoid paying the new rate.
#state_fee#госпошлина#TRP#RP#RVP#VNZH#citizenship#nido#nidorussia
Subscribe: @nido_russia
https://t.me/nido_russia/1661