Что делать если нужно поставить какую-то 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
Trump : $10bn American President
Trump on Thursday sued the US treasury department and Internal Revenue Service for $10bn over the disclosure of his tax returns to the media in 2019 and 2020.
In a complaint filed in Miami federal court, Trump, his adult sons, and his namesake company said the agencies failed to take “mandatory precautions” to prevent former IRS contractor Charles Littlejohn from leaking their tax returns to “leftist media outlets”, including the New York Times and ProPublica.
The plaintiffs said they suffered “significant and irreparable harm” to their reputations and financial interests, and may seek punitive damages because the leaks were either willful or resulted from gross negligence.
Thursday’s lawsuit puts Trump in the unusual position of suing government agencies that are part of the executive branch, which he leads.
The IRS is part of the treasury department. Neither agency immediately responded to requests for comment after business hours.
Scott Bessent, the treasury secretary and acting IRS commissioner, is not a defendant. Other plaintiffs include Donald Trump Jr, Eric Trump and the Trump Organization.
Trump has filed many lawsuits in his personal capacity, often for large sums and as a result of reporting by various media, since winning a second White House term in 2024.
He sued the New York Times and book publisher Penguin Random House for $15bn over articles and a book he said were intended to undermine his election prospects in 2024.
Trump is separately seeking $10bn from the Wall Street Journal over an article discussing a birthday greeting for Jeffrey Epstein, and $10bn from the BBC over its editing of a speech preceding the January 6 storming of the US Capitol.
In Thursday’s complaint, Trump and the other plaintiffs said the New York Times published at least eight articles, and ProPublica published at least 50 articles, based on Littlejohn’s disclosures.
The leaks “caused plaintiffs reputational and financial harm, public embarrassment, unfairly tarnished their business reputations, portrayed them in a false light and negatively affected President Trump, and the other plaintiffs’ public standing”, according to the complaint.
Prosecutors charged Littlejohn in September 2023 with leaking tax records of Trump and thousands of other wealthy Americans to the media, saying he was motivated by a political agenda.
#trump#sue#milliards#newyorktimes#UStreasury
📱American Оbserver - Stay up to date on all important events
🇺🇸
A French Woman gets paid for doing nothing for 20 years, now she sues ⚖️
Sometimes real life seems stranger than fiction, and this particular incident seems so! At a time when the need for work-life balance ⚖️, and most employees feeling burnt out 😓 has become a matter of great discussion, news is that a woman has now sued her company for paying her to do nothing! 💸
What might sound like a dream situation for many—getting paid without doing any work 😴—has turned into a nightmare for 59-year-old woman named Laurence Van Wassenhove.
She is taking Orange, one of Europe’s largest telecom companies 📞, to court, claiming that the company left her in professional limbo for more than 20 years—by giving her full salary, but no tasks, no responsibilities, and almost no human interaction 😔.
Speaking to French broadcaster FTV 📺, Van Wassenhove described her situation as “forced inactivity” that made her feel invisible at work 👻.
From being a valued employee to being isolated at work
Van Wassenhove joined Orange in 1993, when it was still France Télécom. After developing epilepsy and hemiplegia—partial paralysis on one side of her body 🩺—she moved from her original role to a secretarial position, drawing on her HR background.
But in 2002, everything stalled. Hoping to transfer to another region 📍, she was declared unfit for the proposed role by an occupational health review.
Instead of finding her an alternative, the company placed her on “standby.” This was the start of a 20-year period of professional exile 😞.
“I was paid, yes but treated like I didn’t exist.”
Despite receiving her salary 💰, Van Wassenhove told Mediapart she faced financial difficulties, eviction threats 🏠, and severe mental health struggles while raising her autistic child 👶. The lack of purpose and social connection drove her into deep depression, she said 😢.
Her lawyer, David Nabet-Martin, argues that Orange’s inaction robbed her of “having a place in society” as a disabled person, inflicting lasting psychological harm 🧠.
How her employer responded
Orange told La Dépêche it had taken her “personal social situation” into account and offered the “best possible conditions” during her absence from active work. The company says it explored ways to reintegrate her, but frequent sick leave prevented progress 🚫.
Van Wassenhove began formally raising the issue in 2015 with the government and the High Authority for the Fight Against Discrimination ✊. She claims little changed, and eventually early retirement was suggested—something she saw as yet another push out of the workforce 👋.
Her case highlights the darker side of prolonged inactivity, challenging the assumption that doing nothing for pay is a luxury 🌟.
As she takes her fight to court ⚖️, it could ignite new debates about disability rights, workplace inclusion, and the real meaning of “having a job” 💼.
#wassenhove#paid#nothing#sue#Orange
👂More on Trump's Ear ⚠️