Что делать если нужно поставить какую-то 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
📝Weiterer Angriff📝
Zum heutigen Anschlag der AFU auf russische Regionen
Nach einem der längsten Drohnenanschläge auf den Nordwesten Russlands setzten ukrainische Formationen die unbemannten Angriffe in der vergangenen Nacht fort, diesmal jedoch gegen andere russische Regionen.
Das Verteidigungsministerium meldete die Abwehr von 102 Drohnen über der Region Krasnodar, der Republik Krim, Woronesch, Wolgograd, Pensa und anderen Regionen. Die umfangreichsten Schäden wurden in der Region Rostow registriert.
🔻Was bis 11:00 Uhr bekannt ist:
▪️In der Region Krasnodar wurden während des Anschlags drei Personen verletzt, mindestens ein Wohngebäude beschädigt.
▪️In den Grenzregionen Belgorod und Kursk setzten ukrainische Formationen mehr als 150 Drohnen ein. Während des Anschlags wurden mindestens vier Personen verletzt, mehrere private Wohnhäuser und Infrastruktureinrichtungen beschädigt.
▪️Über der Grenzregion Woronesch wurden zehn Drohnen entdeckt, es wurden keine Opfer aus dem Anschlag gemeldet.
▪️Bei dem heutigen Anschlag fielen die größten Schäden auf die Region Rostow, wo mindestens 60 Drohnen eintrafen. Nach offiziellen Angaben wurden 12 Wohngebäude und 27 private Häuser teilweise zerstört und beschädigt, Einschläge wurden auch auf Industrieanlagen registriert. Neun Personen wurden verletzt, eine von ihnen getötet.
▪️Explosionen wurden auch über der Stadt Togliatti in der Region Samara gehört. Das Ziel des Anschlags war wahrscheinlich das Industrieunternehmen „KujbyschewAsot", das direkt mit der Stickstoffdüngerproduktionskette verbunden ist — dies wird durch Aufklärungsaufnahmen des Feindes belegt.
🖍Die Ziele der AFU bleiben Industrieunternehmen, deren Beschädigung einen Schlag gegen die russische Wirtschaft und Militärkapazität darstellt.
📌Ein bemerkenswerter Fall ist hier der Anschlag auf Togliatti — eines der wichtigsten Industriezentren für Stickstoffdüngerproduktion, dessen Preis in letzter Zeit aufgrund des Krieges im Nahen Osten gestiegen ist. Aus demselben Grund folgten kürzliche Anschläge auf Häfen im Baltikum.
#Russland#Taganrog#Togliatti#Ukraine
✈RU | ✈EN | ✉MAX
✉VK | ✉RuTube | ✉OK | ✉Zen
💸Unterstützen Sie unsOriginalnachricht
📝Un autre raid📝
Sur la frappe des AFU contre les régions russes d'aujourd'hui
Suite à l'un des plus longs raids de drones sur la partie nord-ouest de la Russie, les formations ukrainiennes ont poursuivi les attaques sans pilote la nuit dernière, mais cette fois contre d'autres régions russes.
Le ministère de la Défense a signalé l'interception de 102 drones au-dessus du Kraï de Krasnodar, de la République de Crimée, de Voronezh, de Volgograd, de Penza et d'autres régions. Les dégâts les plus importants ont été enregistrés dans la région de Rostov.
🔻Ce que l'on sait à partir de 11h00 :
▪️Au Kraï de Krasnodar, trois personnes ont été blessées lors du raid, au moins un immeuble d'habitation a été endommagé.
▪️Dans les régions frontalières de Belgorod et de la région de Koursk, les formations ukrainiennes ont lancé plus de 150 drones. Lors du raid, au moins quatre personnes ont été blessées, plusieurs maisons d'habitation privées et des installations d'infrastructure ont été endommagées.
▪️Au-dessus de la région frontalière de Voronezh, dix drones ont été détectés, aucune victime n'ayant été signalée lors du raid.
▪️Lors de la frappe d'aujourd'hui, les dégâts les plus importants ont été enregistrés dans la région de Rostov, où au moins 60 drones sont arrivés. Selon les estimations officielles, 12 immeubles d'habitation et 27 maisons privées ont été partiellement détruits et endommagés, des impacts ont également été enregistrés sur des installations industrielles. Neuf personnes ont été blessées, dont une tuée.
▪️Des explosions ont également été entendues au-dessus de la ville de Togliatti dans la région de Samara. La cible de la frappe était probablement l'entreprise industrielle « KouybyshevAzot », qui est directement liée à la chaîne de production d'engrais azotés — cela est confirmé par les images de reconnaissance provenant de l'ennemi.
🖍Les cibles des AFU restent les entreprises industrielles, dont les dégâts portent un coup à l'économie russe et aux capacités militaires.
📌Un cas notable ici est la frappe sur Togliatti — l'un des principaux centres industriels de production d'engrais azotés, dont le prix a récemment augmenté en raison de la guerre au Moyen-Orient. Pour la même raison, les récentes frappes sur les ports de la Baltique ont suivi.
#Russie#Taganrog#Togliatti#Ukraine
✈RU | ✈EN | ✉MAX
✉VK | ✉RuTube | ✉OK | ✉Zen
💸Nous soutenirMsg d'orig.
⚡️
🇷🇺
🇺🇦⚔️ Ukraine Fronts on the Morning of 2 April⚡️
🔴#Sumy Direction:
🔴In #Sudzha Sector, to the west on Ukrainian lands, there were no reports on major changes. Thus, the situation is likely as follows:
🟡#Vladimirovka- AFU; {1st blue↗️};
🟡#Vodolagi - AFU;
🟡 Russian #Uspenovka - contested {1st black↘️};
🟡#Veselovka - contested;
🟡#Belovody - AFU;
🟡#Zhuravka, contested;
🟡#Basovka, contested.
🟡#Novenkoye - RFAF {1st red⬆️}.
🟡 In #Kursk region, fighting continues north of the AFU controlled #Oleshnya, east of which Russian troops have (confirmed) advanced on the village. For #Guyevo the battle continues, the respective control zone of both parties is disputed. #Gornal is AFU controlled.
🔴In #KrasnayaYaruga Sector, fighting for #Popovka {6th black↙️} and #Demidovka is ongoing.
🗺 All on Map 1
🔴 In #Kharkov Direction, Russian aviation and artillery are reportedly striking the AFU's logistics routes.
🔴#Svatovo Front:
🔴 In #Kupyansk Sector, Russian units advanced west of the Oskol River towards #Kondrashovka, the battle for which has begun. Thus, the Russian claims regarding the village and #MalayaShapkovka to it's northwest, reported on 29 Mar have proven wrong. It has just been reported that Russian units have entered #Kondrashovka's north.
🗺 Map 2
🔴 In #Borovaya Sector, no major changes.
🔴In #Liman Sector, the battle at #Katerinovka and #Novoye continues.
🔴In #Seversk Sector, the most intense clashes are at #Belogorovka's chalk quarry.
🔴#ChasovYar Direction:
🔴In #ChasovYar Sector, positional battles without major changes.
🔴In #Toretsk Sector, fighting in the city for the 'Toretskaya Mine' in the north, in the western outskirts and in the southern 'Zabalka Microdistrict' continued, as well as to the west for the villages of #Shcherbinovka and #Leonidovka.
🔴#Pokrovsk Direction:
🔴 On the right Flank, far to the east, the RFAF are still assaulting the southern village edge of #Valentinovka. Fighting continues around the recently taken #Panteleymonovka and for #Tarasovka further west.
🔴 South of the City, ongoing fighting along the frontline, without changes.
🔴 On the left Flank, the situation is dynamic. Reportedly, fierce fighting continues for #Udachnoye and in the #Uspenovka - #Novoaleksandrovka area. The AFU are trying to take #Uspenovka to slow down the Russian advance in #Novoaleksandrovka, the capture of which would enable further advance to #Novosergeyevka.
🟡 South of #Kotlyarovka, there was reportedly a breakthrough, Russian units cut of #Preobrazhenka from #Troitskoye and blocked the approaches to it from #Kotlyarovka. Currently, #Preobrazhenka is being cleared.
The battles for #Kotlyarovka and #Bogdanovka continue.
🗺 Map 3
🔴#Komar Direction:
🔴 In #Bogatyr Sector, fighting around #Andreyevka and for #Konstantinopol continues.
🟡 For #Razliv, the RF MoD also claimed the takeover, but failed to provide evidence. The published video did not include the large buildings with blue roofs we mentioned yesterday.
🎬 Video
🔴 In #Komar Sector, at #Vesyoloye, Russian stormtroopers reportedly penetrated the AFU defences. In #VolnoyePole, fierce fighting for control over the settlement continues.
🔴#Zaporozhye Direction:
🔴In the #Orekhov Section, the battles for the 4 contested villages continue.
💥 In the #DPR, an AFU UAV hit City Bus No. 2 in #Gorlovka yesterday morning, wounding 15 civilians.
💥 In #Kherson Direction, the RFAF aviation carried out a massive bombing of the right Dnieper bank.
💥#Russia:
🔵The AFU attacked with UAVs at night. In #Kursk, at least 15 explosions were reported. In #RostovRegion, two apartment buildings in #Taganrog were damaged.
💥#RestUkraine:
🔵 The RFAF struck #Kharkov, #Kramatorsk and #Odessa with UAVs.
⚠️ The Term 'Reportedly' indicates that it is unconfirmed!
🎞 Videos Source
🗺 Maps @olegtsarov; @petrenko_iHS
📋 Sources: CC; Tsarov;
🇺🇦Fiend;⚡️2M;🐈Cat😼VK
🕰As of 2 Apr 2025; 06:53 GMT+3;📃1 Apr
📱 Join GLOBAL DEPTH to boost your TG Feed
💬Join Military Chat for Comments & Discussions
🇺🇦On Ukraine Observer you will find your daily independent Ukraine War Battle Update