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

Пребарај: #setbacks

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

@american_observer · Post #4762 · 03.01.2026 г., 21:08

🔠🅰️🔠🔠2️⃣ An oft-heard prediction in Kyiv a year ago held that when Trump realised Putin was not serious about peace, he would pivot to backing Ukraine fully, disregarding the Biden administration’s red lines and fear of escalation. On Friday, Zelenskyy appointed his longstanding military intelligence head, Kyrylo Budanov, to be his chief of staff, after the resignation several weeks ago of Andrii Yermak, his closest advisor, in a corruption scandal. Budanov, a mercurial and charismatic figure known for planning audacious operations against Russia, has good contacts with western intelligence agencies and also maintains contacts with Russia over prisoner exchanges. His appointment could signal a new approach to security and negotiations from Kyiv. The coming year may also prove a challenging one for Zelenskyy politically, as the five-year presidential term to which he was elected in spring 2019 nears the seven-year mark. Martial law in Ukraine prevents the holding of elections, and while there is widespread criticism of Zelensky’s leadership on a range of factors, the impossibility of a wartime election is one point on which there is a broad consensus across the Ukrainian political spectrum. Valerii Zaluzhnyi, the former commander of Ukraine’s army and current ambassador to London, is widely seen as the most viable electoral challenger to Zelensky. Zaluzhnyi has turned down previous offers to join Zelensky’s electoral team and is biding his time, having been sold on the idea of a political run but aware of the damage a competitive election could cause to Ukraine’s fragile wartime society. “He’s not making any active preparations for a campaign, and his public position is that while the war continues he is not thinking about elections and not preparing for them,” said a source close to Zaluzhnyi. “Time will tell whether he goes into politics.” The year ended with Russia claiming Ukraine had launched a massive drone attack on Putin’s residence, an act it said would be met with a tough response. Moscow provided no evidence to back up the claim, with Kyiv insisting the whole story was fabricated, and the CIA reaching the same conclusion, according to US media outlets. It was a reminder of how easy it would be, even if a ceasefire was agreed around elections or as part of a deal, for Russia to invent a thin pretext to relaunch its war. #trump#peace#plan#setbacks#zelensky#russia 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #4761 · 03.01.2026 г., 20:57

Trump’s Peace Plan Can Turn Into one of the biggest political setbacks 🔠🅰️🔠🔠1️⃣ “I would give anything in the world if, in this address, I could say that peace will also come in just a few minutes,” Zelensky said in a message to the Ukrainian people released just before midnight on New Year’s Eve. Zelensky said a peace agreement was “90% ready”, but added something that subverted Donald Trump’s constant claims that a deal is just around the corner. “Those 10% contain, in fact, everything,” he said. It is almost a year since Trump took office and promised to end Russia’s war on Ukraine within 24 hours. That never seemed possible, but as 2025 came to a close a new flurry of US diplomacy began, accompanied by more optimistic statements about peace. The talks were kicked off by the leaking of a peace plan drafted by Russia and the US. Washington told Zelensky that Ukraine would have to give up the Donbas region, while the US army secretary, Dan Driscoll, gathered diplomats from Nato countries in Kyiv for what one person present described as “a nightmare meeting” to tell them Ukraine should sign up to the deal now or face a worse one in future. Zelensky, in concert with his European allies, managed to stave off the plan, which would have felt like a capitulation to most Ukrainians, and started work with the Americans on a new kind of plan. But even if Ukraine and the US are now “90% ready” with that plan, the new year begins with a sense that peace remains elusive. There is little to suggest Russia will jump on board, and however much Trump claims Putin wants peace, Russian officials have made clear they will only sign up to an agreement that deals with what they call the “root causes” of the war. For many Ukrainians, this new year has been the hardest psychologically since the war began. At the start of 2023 there was still some hope that Ukrainian military success would put Russia on the back foot and lead to something approaching victory. By 2024 this looked much less likely, but some semblance of hope remained. When 2025 arrived, it was already clear that victory on the battlefield was not imminent, but the election of Trump for a second term boosted hopes in Kyiv that the wildcard politician could benefit Ukraine. #trump#peace#plan#setbacks#zelensky#russia 📱American Оbserver - Stay up to date on all important events 🇺🇸