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

Пребарај: #koktebellanding

当前筛选 #koktebellanding清除筛选
Russian MFA 🇷🇺

@MFARUSSIA · Post #27942 · 04.01.2026 г., 16:02

🌟 In early January 1942, the Kerch-Feodosia amphibious landing operation by the Red Army (December 26, 1941 — January 2, 1942) concluded — the offensive when the legendary #KoktebelLanding — a daring operation by a reconnaissance unit of the Red Navy seamen in the Koktebel Bay, where they engaged in a heavy uphill combat with the Nazi garrison — was carried out. Fearless seamen, who were tasked with an important strategic mission, which consisted of engaging the German garrison in combat to distract it from Feodosia, performed deceptive tactical manoeuvre hampering a huge number of the German troops along the Koktebel shore at the time when the main Red Army forces attacked on the Kerch peninsula. Despite the enemy’s superiority in manpower and equipment, the Koktebel landing was carried out successfully, with the main mission being completed. Soviet Red Nave seamen showed unparalleled courage and heroism: under harsh and fierce weather conditions (a five-category storm and a -20°C frost), engaging combat being waist-deep in the icy water, the seamen were fighting to death, selflessly assisting their comrades to defend Crimea against the Nazi invaders. Thanks to the heroic feat of Soviet seamen in Koktebel, the Red Army was given the opportunity to reach Feodosia on land and firmly entrench on the Kerch bridgehead. On January 5, a group of Red Army soldiers landed in Yevpatoria, having driven the Romanian invaders out of the city. 🎖 The success of the Koktebel landing turned the tide in the Battle of Sevastopol —the Nazis hastened to redeploy some of their divisions to Kerch so as to deter the Red Army attacking. Thus, the defenders of Sevastopol gained the necessary time: the city garrison could regroup the forces and throw all their strength to fend off the enemy. *** The Koktebel landing December 1941 On the night of December 28-29, 1941, during the Kerch offensive, a reconnaissance unit of 29 volunteering Red Navy seamen reached the Koktebel Bay on board of the D-5 'Spartakovets' submarine. Once arrived at the destination of the mission, the unit received an order — to land ashore and launch an assault on the Nazi-occupied Koktebel village, while the main Red Army ground forces were reaching Feodosia. In the early morning of December 29, at 3:30 a.m., the Soviet seamen launched the attack. Despite dense machinegun fire and enemy mines, the unit broke through the sheer hell — the seamen reached the shore and engaged in combat with the German and Romanian troops. Our seamen's surprise attack tied down the enemy garrison in Koktebel for several days until the main Red Army forces approached. By January 1, the Red Army assault group, which successfully landed in Feodosia, finally reached Koktebel and joined their comrades — the heroic seamen who were selflessly fighting till the end. Together they crushed the enemy and further continued liberation of Crimea. The heroic Victory in Koktebel was achieved at a high cost: according to various estimates, only 10 out of the 29 seamen survived. *** In 1975, marking the 35th Anniversary of the Great Victory, in Koktebel (Republic of Crimea) a monument to the Heroic 29 Red Navy seamen was unveiled. The memorial stone bears the inscription: To the soldiers who participated in the landing and died for the Crimean land during the Great Patriotic War. 🕯 The monument is located beside the mass grave where the seamen, who perished in the Koktebel operation, found their eternal rest. #Victory80#WeAreProud#WeRemember