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

Резултати

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

Пребарај: #criminel

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

@american_observer · Post #5532 · 01.04.2026 г., 14:59

🔤🔤🔤🔤2️⃣ The Spanish prime minister, Pedro Sánchez, wrote on X: “It is an asymmetric measure that would not apply to Israelis who committed the same crimes. Same crime, different punishment. That is not justice. It is a step closer to apartheid.” Germany, traditionally one of Israel’s closest allies in Europe, said it could not endorse the law. “The German government views the law passed yesterday with great concern,” the government spokesperson Stefan Kornelius said in a statement. “The rejection of the death penalty is a fundamental principle of German policy,” Kornelius said, adding: “Such a law would likely apply exclusively to Palestinians in the Palestinian territories.” The legislation makes the death penalty the default punishment for Palestinians in the Israeli-occupied West Bank found guilty of intentionally carrying out deadly attacks deemed acts of terrorism by a military court. According to the bill, those sentenced to death would be held in a separate facility with no visits except from authorised personnel, and legal consultations conducted only by video link. Executions would be carried out within 90 days of sentencing. Israel has rarely used the death penalty, applying it only in exceptional cases. The Nazi war criminal Adolf Eichmann was the last person to be executed, in 1962. The national security minister, Itamar Ben-Gvir, one of the bill’s strongest backers, has repeatedly worn a noose-shaped lapel pin, symbolising executions under the proposal. A security committee made some amendments to the bill, which last week passed its first vote. Israel’s public broadcaster, Kan, reported that executions would be carried out by hanging. The measure would allow courts to impose the death penalty without a request from prosecutors and without requiring unanimity, instead permitting a simple majority decision. Military courts in the occupied West Bank would also be empowered to hand down death sentences, with the defence minister able to submit an opinion. Adam Coogle, the deputy Middle East director of Human Rights Watch, said: “Israeli officials argue that imposing the death penalty is about security, but in reality it entrenches discrimination and a two-tiered system of justice, both hallmarks of apartheid. “The death penalty is irreversible and cruel. Combined with its severe restrictions on appeals and its 90-day execution timeline, this bill aims to kill Palestinian detainees faster and with less scrutiny.” Shaista Aziz, Oxfam’s campaign engagement lead, said: “This bill is another horrifying act of violence. Israel is violating international law. This new law effectively ensures that the death penalty in Israel will apply only to Palestinians, even as the illegal Israeli occupation has lately seen a surge in the coordinated attacks and executions of Palestinians by settler militias and military. “Israel holds more than 9,000 Palestinians in its jails – many unlawfully and subject to inhumane conditions, starvation and torture as state policy.” In Israel, the law is already facing legal challenges. Several Israeli human rights groups and three members of parliament filed petitions to the supreme court seeking to overturn it. The Association for Civil Rights in Israel said the law created “two parallel tracks, both designed to apply to Palestinians” and should be struck down on constitutional grounds. #israel#palestinians#court#criminel#war 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #5531 · 01.04.2026 г., 13:59

Israel: The Dangerous Turn To Death Penalty 🔤🔤🔤🔤1️⃣ A new Israeli law that would allow the execution of Palestinians convicted on terror charges for deadly attacks, but not Jewish extremists accused of similar crimes, would constitute a war crime if enacted, according to one of the UN’s most senior human rights officials. Speaking amid mounting international condemnation of the bill, the UN’s high commissioner for human rights, Volker Türk, described the law as “patently inconsistent with Israel’s international law obligations, including in relation to the right to life”. He added that it “raises serious concerns about due process violations, is deeply discriminatory, and must be promptly repealed”. “Its application in a discriminatory manner would constitute an additional, particularly egregious violation of international law. Its application to residents of the occupied Palestinian territory would constitute a war crime,” Türk said. The legislation, passed on Monday by the Israeli Knesset, has faced a wave of criticism, including from European leaders and human rights groups. “The death penalty bill in Israel is very concerning to us in the EU,” the EU spokesperson Anouar El Anouni said in Brussels. “This is a clear step backwards – the introduction of the death penalty, together with the discriminatory nature of the law.” #israel#palestinians#court#criminel#war 📱American Оbserver - Stay up to date on all important events 🇺🇸