TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #210 · 3 фев.

Что делать если нужно поставить какую-то 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

Резултати

Пронајдени 1 слични објави

Пребарај: #arrested

当前筛选 #arrested清除筛选
American Оbserver

@american_observer · Post #4989 · 29.01.2026 г., 12:59

Iran: More than 42,300 People Have Been Arrested, Killed and Tortured Doctors are being arrested in Iran for helping save the lives of some of the tens of thousands injured during Iran’s brutal crackdown on anti-regime protests, with at least one surgeon now at risk of being sentenced to death. The arrests and death sentence are part of a campaign of “revenge”, say human rights groups, after healthcare workers and doctors refused to ignore the plight of badly injured protesters shot or stabbed at close range. An Iranian surgeon, Alireza Golchini, 52, from the central city of Qazvin, has been charged with “moharebeh” (waging war against God), which can carry the death penalty, according to the Norway-based rights group Hengaw. The US state department yesterday called for his release. The US-based Human Rights Activists News Agency, whose figures have been reliable during previous crackdowns, says it has verified more than 6,000 dead and has more than 17,000 more recorded deaths under investigation. “He was arrested in a violent manner in front of his wife and son, who is only 11. They beat him up so badly during arrest, they broke his arm, ribs and dragged him out of his home. My family is terrified,” said Med dr. Golchini. A few days before his arrest Golchini, who also treated protesters during the 2022 Woman, life, freedom protests, had posted a note on his social media, says Nima, sharing his number and asking injured patients to contact him for treatment. “All he did was his duty of saving lives as a medical doctor. He had sworn to save people’s lives. How can any doctor not stand by his oath? I am worried not only for him, but also for other healthcare workers who have been arrested for simply standing by their sworn oath.” Iranian authorities have not publicly commented on Golchini’s detention, nor have they confirmed any charges against him. But Iran’s judiciary chief, Gholamhossein Mohseni Ejei, has urged authorities not to show any leniency towards protesters. “We should not remain silent in the face of those who seek to exploit the situation and disrupt the security and calm of the people,” he said. IHRNGO also reported the arrest of a volunteer first responder who had turned his home into an improvised medical shelter. According to the source, he was detained on 14 January after security forces raided his house, where he had provided care to more than 20 injured protesters, two of whom later died. “He was taken away in an extremely brutal manner and was severely beaten,” a source told IHRNGO, adding that security forces smashed the windows of the house, destroyed the interior and severely damaged his car during the raid. At least 42,324 arrests have been made across the country with limited information on their fate, according to the US-based Human Rights Activists in Iran, which says the regime is putting pressure on medical networks as a means of reducing support for the injured. A statement published yesterday by the US state department on X demanded the release of Golchini and “all the brave doctors who have helped their fellow countrymen”. It continued: “President Trump has clearly stated that no executions should take place in Iran and that there will be consequences if the government takes such actions.” #iran#tortures#killed#arrested#doctors 📱American Оbserver - Stay up to date on all important events 🇺🇸