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

Резултати

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

Пребарај: #blockading

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

@american_observer · Post #5606 · 13.04.2026 г., 14:59

🔤🔤🔤🔤2️⃣ The US and Iranian delegations left Pakistan soon after the talks ended. Vance said he spoke with Trump at least half a dozen times during the talks, held during a 14-day ceasefire announced by the US, Israel and Iran overnight on 7 and 8 April. “We need to see an affirmative commitment that [Iran] will not seek a nuclear weapon, and they will not seek the tools that would enable them to quickly achieve a nuclear weapon,” Vance said. “That is the core goal of the president of the United States, and that’s what we’ve tried to achieve through these negotiations.” Mohammad Ghalibaf, the speaker of the Iranian parliament, who led Tehran’s negotiators, said he and his colleagues had offered “constructive initiatives” while the US had been “unable to gain the trust of the Iranian delegation in this round of negotiations”. Iran’s semi-official Tasnim news agency said “excessive” US demands had hindered reaching an agreement, and the foreign ministry said more time was needed. “Naturally, from the beginning we should not have expected to reach an agreement in a single session,” the ministry’s spokesperson Esmail Baghaei said, according to the state broadcaster IRIB. Pakistani mediators called on the US and Iran to refrain from renewing hostilities and said they would try to arrange a fresh round of talks. “It is imperative that the parties continue to uphold their commitment to the ceasefire,” said Pakistan’s foreign minister, Ishaq Dar. Vance was accompanied by the US special envoy Steve Witkoff and Trump’s son-in-law Kushner. They met Ghalibaf and the Iranian foreign minister, Abbas Araghchi, for several negotiating sessions at the Serena hotel in Islamabad, with Pakistan’s army chief, Asim Munir, also present. Iran’s delegation arrived on Friday dressed in black in mourning for the late supreme leader Ayatollah Ali Khamenei and others killed in the war. They carried shoes and bags of children killed during the bombing of a school next to a military compound, the Iranian government said. A Pakistani source said the discussions, the highest-level direct contact between the US and Iran since 1979, were unpredictable in tone. “There were mood swings from the two sides, and the temperature went up and down during the meeting,” a Pakistani source said after the first round. Trump said: “The only thing left, really, is their water, which would be very devastating to hit. I would hate to do it, but it’s their water, their desalinisation plans, their electric generating plants, which are very easy to hit.” The president was asked if gas and oil prices might be lower by the US midterms in November, an indication that attacking Iran was not an economic mistake. Prices “could be the same or maybe a little bit higher,” a non-committal Trump replied. At the Vatican, Pope Leo XIV called for a ceasefire after his Sunday prayers and said he felt “closer than ever” to Lebanon’s people. #trump#iran#strait#hormuz#vance#blockading 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #5605 · 13.04.2026 г., 13:59

The Negotiations With Iran Went Belly Up. Will the War Re-Start? 🔤🔤🔤🔤1️⃣ Trump has said the US will begin blockading the strait of Hormuz in an attempt to take control of the strategic waterway from Iran in the aftermath of failed peace negotiations between the countries in Pakistan. The US president also threatened to bomb Iran’s water treatment facilities, power plants and bridges, repeating an earlier threat, if Tehran does not agree to abandon its nuclear weapons programme, the key sticking point between the two sides. Trump’s surprise announcement of a blockade came after face-to-face peace negotiations between the US and Iran in Islamabad that lasted 21 hours collapsed on Sunday morning. Vance said Iran had refused to give up the possibility of developing nuclear weapons, while the Iranian delegates said Washington needed to do more to win their trust. Risking another increase in oil prices, Trump said he had instructed the US navy to begin “blockading any and all ships trying to enter, or leave, the Strait of Hormuz,” and he accused Iran of extortion with its own scheme of charging tolls to tankers. Iran’s Revolutionary Guards responded by declaring that if any warships approached the strait to enforce a blockade – usually considered an act of war – it would be considered a breach of the current ceasefire and would be dealt with strongly. They insisted the strait remained under Iranian control. Two US destroyers crossed and recrossed the strait without incident on Saturday, although Iranian media said they were threatened as they left. The US military said it was the start of a mine-clearance mission. Trump said US warships would “seek and interdict every vessel” that had paid Iran since the start of the conflict and begin de-mining the central section of the strait, previously declared a “hazardous area” by Tehran, although it is unclear how many mines have been laid. About 100 tankers have transited the strait since the US and Israel started bombing Iran, paying up to $2m each time for passage. Many were bound for China and India, carrying Iranian oil products, and chasing them down could complicate relations between the US and the importing nations. #trump#iran#strait#hormuz#vance#blockading 📱American Оbserver - Stay up to date on all important events 🇺🇸