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 слични објави

Пребарај: #dodik

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

@american_observer · Post #5691 · 23.04.2026 г., 14:00

The War Between the EU and the US Is Real Than Never The EU risks a confrontation with Trump after it sought to stall the awarding of a lucrative Balkans pipeline contract to a company fronted by his personal lawyer, documents seen by the Guardian show. Brussels has clashed with Trump over trade, Ukraine and military spending, but the intervention in the Southern Interconnection pipeline project appears to mark the first time it has challenged a commercial venture by those close to the president. The pipeline will run through Bosnia and Herzegovina. Under what Bosnian sources say have been months of pressure from US officials, its leaders have been moving quickly to award the contract to a previously little-known company based in Wyoming. AAFS Infrastructure and Energy was incorporated in November last year and has not disclosed its owners. It is fronted by two leading members of Trump’s campaign to overturn his 2020 election defeat : Jesse Binnall, a lawyer who defended him against allegations of inciting the Capitol riots after his defeat, and Joe Flynn, the brother of the president’s former national security adviser. Despite lacking any apparent track record, AAFS is planning to invest $1.5bn in the pipeline and other Bosnian infrastructure projects, its local representative has said. In March, lawmakers approved legislation that Transparency International said would set a “dangerous precedent” by stipulating that the contract must go to AAFS without a tender. Days later, Brussels’ representative in Sarajevo delivered a private warning to Bosnia’s leaders that they were jeopardising the country’s hopes of joining the EU. In a letter sent on 13 April, obtained by the Bosnian investigative outlet istraga.ba and seen by the Guardian, the EU official Luigi Soreca wrote that, under an energy agreement between Bosnia and Brussels, it was “crucial that draft laws are thoroughly coordinated” with the EU. Soreca said Brussels should have a say in the pipeline legislation. “In this way, Bosnia and Herzegovina can continue to progress on its European path and avoid missing out on opportunities for further integration, as well as financial opportunities,” he said. Binnall has said the pipeline is a “priority for the Trump administration”. Asked about the EU’s intervention, he said: “AAFS will never lose sight of what truly matters in this project: delivering energy security and fostering economic development for the people of Bosnia and Herzegovina. We are committed to working closely with all relevant authorities to develop the infrastructure needed to make this vision a reality.” By connecting Bosnia to a liquefied natural gas terminal off the Croatian coast, the pipeline would allow US gas to reach a country that depends on Russia for its entire supply. After Putin launched Russia’s full-scale invasion of Ukraine in 2022, Brussels set a deadline for EU members – plus aspiring members, such as Bosnia – to stop buying Russian gas by 2028. Nonetheless, Brussels faces the prospect of a crucial new piece of Europe’s energy chessboard falling under the control of not just a US company, but one personally connected to an antagonistic president. Binnall and Flynn are not the only ones from Trump’s circle to have shown an interest in Bosnia. Joe Flynn’s brother Michael – a former US intelligence chief whose conviction for lying to the FBI about his dealings with Russia was quashed by a pardon from Trump in 2020 – has been lobbying for the head of Bosnia’s Serb nationalist faction. The lobbying campaign succeeded in October in having US sanctions lifted from Milorad Dodik, the Bosnian Serb leader who has been undermining the 1995 peace accord that ended a three-year war in which more than 100,000 people were killed. In April, Donald Trump Jr, who runs the family business empire, visited Sarajevo. Although neither he nor Michael Flynn appear to be directly involved in the pipeline project, Dodik has thrown his support behind it. #trump#dodik#gaz 📱American Оbserver - Stay up to date on all important events🇺🇸

Tutto Elezioni

@tuttoelezioni · Post #1390 · 23.11.2025 г., 10:02

#BosniaErzegovina🇧🇦 #RepublikaSrpska #Presidenziali 🗒Breve panoramica della Republika Srpska La Repubblica Serba (Republika Srpska) è una delle due entità che compongono la Bosnia ed Erzegovina, insieme alla Federazione di Bosnia ed Erzegovina. Nata dagli Accordi di Dayton del 1995, è l’area in cui è maggioritaria la popolazione serba di Bosnia (nella Federazione si concentra la popolazione croata e bosgnacca). Il centro amministrativo della Repubblica è Banja Luka. La Republika Srpska è politicamente dominata da partiti nazional-conservatori serbi, in particolare l’Alleanza dei Socialdemocratici Indipendenti (#SNSD|Nazionalisti serbi russofili) di Milorad #Dodik, e i rapporti con il governo di Sarajevo sono spesso tesi, soprattutto sul tema dei poteri delle istituzioni centrali e dell’Alto Rappresentante. Le elezioni nell’entità hanno sempre un impatto significativo sull’equilibrio complessivo della Bosnia ed Erzegovina. ❓Come si vota? Per le elezioni presidenziali, è previsto un unico turno ed è eletto Presidente il candidato che ottiene il maggior numero di voti. Il mandato dura 4 anni. @TuttoElezioni