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

Резултати

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

Пребарај: #murom

当前筛选 #murom清除筛选
DruschbaFM - English

@druschbaFm_en · Post #52098 · 15.03.2025 г., 07:56

⚡️🇷🇺🇺🇦⚡️ Two Majors #Summary for the Morning of 15 March 2025; 06:29 (GMT+3)⚡️ 🛡More than 20 UAVs were downed by air defence and EW means over the #Voronezh region at night. The governor of the #Bryansk region also reported that an UAV attack had been repelled. Local media reported explosions (15-20) over #Volgograd, with one drone downed near 'Sarepta Station.' The likely target was the local oil refinery, with footage of a fire emerging. During the day, a drone crashed in the centre of #Dzhankoy (#Crimea), injuring 2 women. The UAV damaged a café, and shrapnel struck 2 private houses and a church. There were 3 wounded. 🎯 Russian Forces, in turn, targeted industrial zones and the port in #Odessa and its surroundings with Geranium drones. A fire broke out at an electrical substation following one of the strikes, and the regional administration reported that #Chernomorsk (#Ilyichevsk) was completely blacked out due to damage to the energy infrastructure. The enemy also reported strikes on #Chernigov, #Pavlograd, #Cherkassy, #Starokonstantinov, the Bogodukhovsky district of the #Kharkov region, as well as the #Vinnitsa and #Kiev regions. 🔹 In #Kursk Region, the destruction of remaining enemy forces attempting to retreat into the #Sumy region continues. Trump has stated that thousands of AFU militants are encircled. The final settlements left to be liberated are #Gogolevka, #Gornal, #Oleshnya, and #Guyevo. The enemy is striking liberated territories. AFU Nazis targeted the local history museum in #Sudzha, an architectural monument from the late 19th century. A museum employee, who had remained in the city during the occupation and had come to inspect the building, was killed. 2 other employees were wounded. Since 12 March, 209 residents have been evacuated from the liberated settlements. Amid the Russian Army’s advance and the Supreme Command’s objective of creating a buffer zone, mandatory evacuation has begun in 8 villages near the border in the #Yunakovka and #Miropolye communities of the #Sumy region. Russian forces have already pushed into enemy territory towards #Basovka and #Zhuravka. Until demining operations are completed, the authorities in the region have imposed temporary entry restrictions in 122 settlements across 6 districts bordering #Ukraine. 🔹 In the North of #Kupyansk Direction, reports indicate clashes with AFU forces near #Figolevka on the right bank of the Oskol. 🔹 In #Pokrovsk Direction, fighting continues near #Udachnoye, #Kotlino, #Peschanoye, #Shevchenko, and #Tarasovka. The enemy claims that Russian units, freed up after the liberation of #Konstantinovka, have been redeployed to #Pokrovsk to increase pressure. 🔹 On the #Vremyevka Ledge, the 'Group of Troops East' continues advancing towards #Bogatyr west of the village. Fighting is ongoing in the areas of #Dneproenergiya and #Burlatskoye. 🔹 On the #Zaporozhye Front, reports indicate Russian success near #Shcherbaki and #MalyeShcherbaki.🗺👆Russian units continue to assault enemy positions in the forest plantations. From the southern side, airborne troops have entered #Shcherbaki, assaulting enemy fortifications and strongpoints. The enemy has pulled back its main forces, leaving observation posts in the village manned with machine gun and rifle crews, supported by artillery and kamikaze drones. #Shcherbaki is nearly cleared. Assault groups of the Russian Airborne Forces are advancing from the south towards #MalyeShcherbaki and from the east towards #Shcherbaki. 💥 In #Belgorod Region, the enemy continues heavy strikes. #Valuyki, #Kukuyevka, #Murom, #Shebekino, #Tishanka in the Volokonovsky district, and #YasnyeZori in the Belgorod district are under attack. 💥 In #Gorlovka (#DPR), a Nazi drone strike injured a 1951-born woman and a 1981-born man. A 1970-born man was injured by enemy barrel artillery. 📱 Join GLOBAL DEPTH to boost your TG Feed 💬Welcome to Military Chat & Ukraine Observer 🇺🇦On Ukraine Observer you will find your daily independent Ukraine War Battle Update