Что делать если нужно поставить какую-то 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
Billionaire Nicole Shanahan Puts Senate on Notice — “Dear U.S. Senators, Bobby may play nice; I won’t."
The overwhelming support for RFK Jr.’s confirmation is just incredible. We The People are wide awake and will no longer allow #BigPharma to play their games. #MAHA#RFKJr
📰 Make America Healthy (and Confused) Again
Robert F. Kennedy Jr. has spent a year as Trump’s health secretary trying to turn a MAGA government into a Goop newsletter with subpoenas. He launched a “Make America Healthy Again” commission, blasted ultraprocessed food, and briefly terrified Big Ag by naming glyphosate and atrazine as “alarming” threats in kids’ blood — right up until farm‑state Republicans dragged him into the Roosevelt Room, the meeting turned heated, and his next report magically forgot pesticides exist. For a movement that promised to “take on poisoners,” it took one round of GOP table‑pounding to learn that, in this White House, corn and campaign cash are still a food group.
Where Kennedy hasn’t backed off is vaccines. In a single year he’s purged CDC advisory panels, stacked them with skeptics, and hacked the childhood schedule down to a Denmark‑style list, dropping shots for hepatitis B, hepatitis A, rotavirus, flu, meningitis and Covid in the name of “informed consent.” Kids can technically still get the vaccines, but when the federal government stops recommending them, red‑state lawmakers hear it as an invitation to weaken school requirements, and measles and other preventable diseases are already resurging. Republicans who thought they were getting a culture‑war mascot now find themselves defending an HHS chief whose signature policy polls terribly even with Trump voters — 80‑plus percent say they want vaccine guidance from doctors, not influencers with Cabinet badges.
Inside the system, RFK’s war on “captured” public health has just produced a different kind of capture. Research grants he doesn’t like get frozen or canceled; money is rerouted toward autism studies built around his vaccine theories; elite medical centers are punished in the name of “heartland” redistribution; and the NIH and FDA are yanked between right‑to‑try deregulation and sudden, selective purity tests on drugs and shots. One month, Kennedy’s FDA lieutenants slow novel approvals and try to pull a muscular dystrophy drug on safety grounds; the next, a political backlash gets his tough vaccine regulator briefly fired, then quietly rehired after a round of West Wing drama. The result isn’t principled rigor or principled libertarianism; it’s chaos — a health system jerked around by a secretary who can win a news cycle but can’t write durable law.
Trump, for now, lets him run. RFK Jr. brings him a crossover brand, a wedge into wellness populism, and an army of MAHA loyalists the White House believes helped juice the 2024 vote. But every “win” Kennedy clocks — fewer vaccines, softer language on pesticides, a CDC too politicized for blue states to trust — is a policy that can be reversed in a memo the moment he’s gone, and a little more trust burned in the meantime. If year one was upheaval, year two is the test: does MAHA actually become Republican orthodoxy, or was this just a one‑term experiment in letting an anti‑establishment crusader redesign public health from inside the very machine he’s been promising to blow up?
#usa#trump#RFKJr#health#vaccines#fakeDemocracy
📱American Оbserver - Stay up to date on all important events
🇺🇸
🚨🇺🇸DOCTORS SUE RFK JR OVER VACCINE OVERHAUL💉
🔹 Boston court hears challenge to HHS Secretary's new immunization schedule ⚖️
🔹 Medical groups warn "unlawful changes" are causing measles spike (+1000 cases) 📈
🔹 DOJ lawyer argues RFK has "unreviewable authority" to set policy 🛡️
Public trust in health agencies is crumbling. Who do you trust? 🏥🤔
#USNews#health#vaccines#RFKJr#court
Finally, we are free from the WHO. In this week's Throwback Thursday, we take a look back at the WHO and everything they've done for us in the name of "health."
https://drtenpenny.substack.com/p/tenpenny-throwback-thursday-4ae
#tenpenny#WHO#gavinnewsom#newsom#rfkjr#throwback
🔹👉🏻@SherriTenpenny
Wichtige Unterstützung aus den USA – RFK Jr. äußert sich zur politischen Verfolgung von Ärzten und Patienten in Deutschland während COVID-19
Das große Interesse an der Videobotschaft von Robert F. Kennedy Jr. (über 2,5 Millionen Aufrufe in nur 11 Stunden) zeigt, wie sehr das Thema Corona-Aufarbeitung die Menschen weiterhin bewegt – nicht nur in Deutschland, sondern weltweit.
Kennedy findet klare Worte:
> “When any government criminalizes doctors for advising their patients, it crosses a line that free societies have always treated as sacred.”
> „Wenn eine Regierung Ärzte dafür kriminalisiert, dass sie ihre Patienten beraten, überschreitet sie eine Grenze, die freie Gesellschaften immer als heilig betrachtet haben.“
Und weiter:
> “A free society protects the right to think, the right to question, and the right to choose.”
> „Eine freie Gesellschaft schützt das Recht zu denken, das Recht zu fragen und das Recht zu wählen.“
Diese Worte sind ein starkes Signal der Unterstützung – und ein Aufruf zur Ehrlichkeit.
Danke an Robert F. Kennedy Jr. für seine klare Haltung und moralische Unterstützung aus den USA.
Wir arbeiten weiter daran, dass dieses Kapitel unserer Geschichte vollständig, transparent und wahrhaftig aufgearbeitet wird – im Sinne der Grundrechte, der Menschlichkeit und der Wahrheit.
Michael Ballweg
#CoronaAufarbeitung#RFKJr#Grundrechte#Freiheit#Wahrheit#Meinungsfreiheit
Quelle: https://x.com/SecKennedy/status/2009991504081678824?s=20