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

Резултати

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

Пребарај: #military

当前筛选 #military清除筛选
Casus Belli Live

@casusbellilive · Post #250723 · 04.04.2026 г., 11:12

Zábery vo vnútri lietadlovej lode Gerald R. Ford ukazujú, že priestory posádky a práčovňa boli zničené. Práčovňa úplne vyhorela, rovnako ako mnoho regálov. Únik videa ukazuje, že požiar bol oveľa vážnejší, než uvádzalo Ministerstvo obrany. #USA#Military 🎯@opersvodki 💬ОС в MAX 🌐Zdroj:@SIL0VIKI 🔗Link:https://t.me/SIL0VIKI/109241 https://t.me/casusbellilive Truth over narrative 24/7 WEB | CONTACT | SHOP 📅Vytvorené: 2026-04-04 12:44:51

America 🇺🇸 News & Politics

@America · Post #10467 · 09.04.2026 г., 13:02

🚨🇺🇸AUTOMATIC DRAFT REGISTRATION COMING DECEMBER 2026 🔹 All American men 18-25 will be auto-registered for military draft — no more self-registration required 📋 🔹 New rule mandated by 2026 Defense Authorization Act signed by Trump, replaces 30-day registration window ⚖️ 🔹 Selective Service will use driver's license and state ID data to automatically enroll millions of young men 🆔 🔹 Registration rates dropped to 81% in 2024 from 84% in 2023 — auto-registration fixes compliance gap 📉 🔹 Penalties for non-registration include $250,000 fines and 5 years prison time for draft dodgers 🚫 Generation Z is NOT ready for this wake-up call 😳⚡ #USNews#military @america

Trump's Ear

@trumpsear_tg · Post #2231 · 06.03.2026 г., 00:02

Meeting aims to accelerate weapons production after recent military operationsPentagon may seek around $50 billion supplemental budget for Middle East operationsTrump administration pressures contractors to prioritize production over shareholder payouts #Trump#Military 👂More on Trump's Ear ⚠️

Trump's Ear

@trumpsear_tg · Post #1981 · 07.01.2026 г., 17:59

The U.S. military attacked Venezuela early Saturday morning, abducting its leader Nicolás Maduro and his wife, who now face narco-terrorism charges in a New York federal court. Eighty Venezuelan and Cuban citizens were killed by U.S. gunfire and airstrikes. At least one U.S. missile struck an apartment building in the port city of Catia La Mar, killing an 80-year-old woman as she slept, seriously injuring another and displacing residents, according to The Associated Press. Trump described the attack as “successful” and “perfectly executed.” A growing number of legal experts and lawmakers have called Saturday’s bombing of Venezuela and the abduction of Maduro illegal under both international law and the U.S. Constitution. #Trump#Military 👂More on Trump's Ear

Trump's Ear

@trumpsear_tg · Post #1941 · 23.12.2025 г., 13:53

President Donald Trump announced the Navy will build a new “Trump-class” battleship as part of the White House push to modernize a fleet that’s been hobbled by years of cost overruns and delays. The new ships are part of Trump’s “Golden Fleet” bid to revive US shipbuilding and address shortfalls in smaller vessels as it seeks to compete against China. The Navy is also pursuing a new frigate based on the Legend-class cutter, dubbed the FF(X), which will be built by Newport News, Virginia-based HII. #Trump#Military 👂More on Trump's Ear

Trump's Ear

@trumpsear_tg · Post #1874 · 05.12.2025 г., 18:02

CNN anchor Abby Phillip on Wednesday flagged what she described as "the most telling sign" that President Donald Trump's administration is trying to hide something about the strikes it conducted against alleged drug boats. Phillip opened her nightly show, "NewsNight," with a montage of shifting claims made by administration officials about the boat strikes. She said the comments made by Secretary of State Marco Rubio were the "most telling" because they showed the administration knows it needs to stick to a pre-determined narrative about the event. She played a clip of Rubio telling reporters that one boat the administration struck in September was "probably headed to Trinidad or some other country in the Caribbean." A few months later, Rubio told another group of reporters that the same boat was traveling to the United States. #Trump#Military 👂More on Trump's Ear

Trump's Ear

@trumpsear_tg · Post #1594 · 02.10.2025 г., 18:05

Donald Trump has said he wants to use American cities as "training grounds" for the military. In an unusual address to hundreds of military leaders assembled from across the world, Trump described "civil disturbances" as the "enemy from within". He added that the situation "won't get out of control once you're involved". It comes after Trump deployed National Guard troops to Washington DC, Los Angeles and Portland, Oregon, in a crackdown on crime and to support immigration enforcement. Defence Secretary Pete Hegseth also spoke, declaring an end to "woke" culture at the Pentagon and announcing new "male-level", physical fitness standards for military officials. The president repeated his criticism of Democratic-led cities including San Francisco, Chicago, New York and Los Angeles and indicated he would continue his policy of using military for law enforcement. "They're very unsafe places and we're going to straighten them out one by one," he said, adding that it would be a "a major part for some of the people in this room". "It's a war from within. Controlling the physical territory of our borders is essential for national security. We can't let these people in," he added. Illinois Governor JB Pritzker accused Trump of using military troops and Immigration and Customs Enforcement (ICE) to "invade and disrupt" US cities. "Our troops and our nation deserve better than you acting as a petty tyrant," he said in a post on X. #Trump#Military 👂More on Trump's Ear ⚠️

123•••910
ПретходнаСтраница 1 од 10Следна