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

Резултати

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

Пребарај: #warsaw

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

@american_observer · Post #4829 · 11.01.2026 г., 20:29

🔠🅰️🔠🔠2️⃣ The Hungarian leader, Imre Nagy, who was later executed for his role in the 1956 rebellion, tried to withdraw the country from the alliance during the uprising. “The Soviet Union’s use of force (…) was a different kettle of fish because it was not involved in a territorial conquest but was trying to protect the integrity of the alliance by preventing the ascent of regimes that might defect,” said Charles Kupchan, a fellow at the Council on Foreign Relations. “In Nato’s case, we’re looking at an alliance that has been unified and enjoyed remarkable solidarity since the beginning of the cold war. So the idea that the United States could find itself at war with a Nato ally really does defy the imagination.” To stop it becoming reality, Denmark could invoke Nato’s Article 4, requesting consultations within the alliance, citing an imminent threat. If the US then attacked and Denmark then tried to invoke Article 5, which provides for the alliance’s other members coming to its collective defence, it could put Washington on a military collision course with the rest of the alliance. Kupchan played down the prospects of such an “other-worldly” scenario and argued that previous internal Nato rows – such as the US’s threats against Britain and France during the 1956 Suez crisis, and the fierce Franco-German opposition to the invasion of Iraq in 2003 – had not led to military conflict. “This is a White House that sees itself as on reality TV,” he said. “We are not yet in the world in which the United States is in the process of getting ready to attack an ally.” Yet even if the current tensions blow over, the long-term impact of Soviet behaviour towards the Warsaw Pact – which splintered in 1989 as one eastern European communist regime after another fell from power – may hold lessons for Nato. “It was really the beginning of the decline of the Soviet Union because they got themselves in a position where they couldn’t trust their own allies, and it was to a considerable extent their own behaviour that caused that,” said John Gaddis, a history professor at Yale University and a biographer of George Kennan, the US diplomat who pioneered the west’s anti-communist containment strategy. “There’s some lessons here about what the purpose of an alliance is. It’s not just deterring adversaries, but also reflecting the interests of the other members, sometimes the smaller members of the alliance. The alliance is a lot stronger if they want to be within it than if they’re coerced by the biggest power in it.” The lessons are easily applicable to the US’s interests in Greenland, where it has had military bases since 1941 after they were established under Franklin Roosevelt as he prepared to enter the second world war on Britain’s side against Hitler. “You can certainly make the argument that Greenland is in a strategic position, and could conceivably be vulnerable years from now to the Chinese or a resurgent Russia,” said Gaddis. “But the Americans already have bases in Greenland. And it seems to me it would be a lot easier to keep them, and, if necessary, expand them, with the cooperation of the Danish government, not with this kind of unilateral provocation. Trump is simply creating unnecessary friction for himself.” #greenland#trump#warsaw#pact#france#war 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #4828 · 11.01.2026 г., 19:59

Why Greenland? The Secret Motives of Trump’s Obsession 🔠🅰️🔠🔠1️⃣ Trump’s echoing of Russia’s talking points in its war against Ukraine has long been a cause for alarm and dismay in the west. Now an even more disturbing Kremlin precedent dating from the cold war is being evoked by the US president’s fixation on taking over Greenland – that of carrying out attacks on military allies. The Soviet Union invaded its allied communist partners twice as it engaged in a long ideological and military standoff with the capitalist west, and openly asserted the right to intervene in the affairs of other allies if they deviated from policies dictated by Moscow. Trump’s repeated assertion that the US “needs” Greenland for national security purposes and his refusal to rule out acquiring it by military force has set Washington on a collision course with Denmark, a Nato ally that has sovereignty over the autonomous, self-governing territory. Trump has said “it may be a choice” between taking control of Greenland and keeping Nato intact. If Trump pressed ahead, he would – perhaps unconsciously – be treading a similar path to that followed by the Soviet Union, which invaded communist-run European allied countries in the Warsaw Pact, the Moscow-dominated eastern bloc’s cold-war equivalent of Nato. Soviet troops invaded Hungary in 1956 to suppress a popular uprising that threatened to topple Budapest’s communist regime, with up to 3,000 people killed in bloody street fighting. In 1968, Moscow staged an invasion – this time including forces from other Warsaw Pact nations – of Czechoslovakia to squash the liberalising Prague Spring, which was led by the country’s communist leader, Alexander Dubcek, who ushered in new freedoms intended to create “socialism with a human face”. In contrast with Trump’s mooted Greenland incursion, the Soviet actions were not mounted in wanton disregard for their impact on the Warsaw Pact but in order to save it. #greenland#trump#warsaw#pact#france#war 📱American Оbserver - Stay up to date on all important events 🇺🇸

Opportunities with Zula

@opportunities_zula · Post #893 · 27.12.2025 г., 10:34

World Leadership Forum 2026 in Poland 🇵🇱 (Fully Funded) Apply: https://opportunitiescorners.com/world-leadership-forum-in-poland/ The Largest Youth Forum taking Place in Warsaw in a Presidential 5 Star Hotel. Perks & Benefits: ✅Round Airfare Tickets ✅Accommodation ✅Meals ✅Invitation Letter ✅Visa Support ✅Certification ✅City tour of Warsaw #OpportunitiesCorners#Poland#Warsaw#WLF

Opportunities with Zula

@opportunities_zula · Post #725 · 07.12.2025 г., 04:41

4 Days Leadership Forum 2026 in Warsaw, Poland 🇵🇱 (Fully Funded) Apply: https://opportunitiescorners.com/world-leadership-forum-in-poland/ The Largest Youth Forum taking Place in Warsaw in a Presidential 5 Star Hotel. Perks & Benefits: ✅Round Airfare Tickets ✅Accommodation ✅Meals ✅Invitation Letter ✅Visa Support ✅Certification ✅City tour of Warsaw #OpportunitiesCorners#Poland#Warsaw#WLF

Opportunities with Zula

@opportunities_zula · Post #589 · 21.11.2025 г., 12:08

World Leadership Forum 2026 in Warsaw, Poland 🇵🇱 (Fully Funded) Apply: https://opportunitiescorners.com/world-leadership-forum-in-poland/ The Largest Youth Forum taking Place in Warsaw in a Presidential 5 Star Hotel. Perks & Benefits: ✅Round Airfare Tickets ✅Accommodation ✅Meals ✅Invitation Letter ✅Visa Support ✅Certification ✅City tour of Warsaw #OpportunitiesCorners#Poland#Warsaw#WLF

Opportunities with Zula

@opportunities_zula · Post #393 · 19.10.2025 г., 07:59

World Leadership Forum 2026 in Warsaw, Poland 🇵🇱 (Fully Funded) Apply: https://opportunitiescorners.com/world-leadership-forum-in-poland/ Perks & Benefits: ✅Round Airfare Tickets ✅Accommodation ✅Meals ✅ Invitation Letter ✅City tour of Warsaw #OpportunitiesCorners#Poland#Warsaw#WLF