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

Резултати

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

Пребарај: #spain

当前筛选 #spain清除筛选
International Geographic

@internationalgeographic · Post #5519 · 21.03.2025 г., 04:50

Seville, #Spain Metropol Parasol (the Metropol umbrella, Spanish The Metropol Parasol, also known as the Mushrooms of Seville, is a concrete and wooden structure located in the Plaza de la Encarnacion. Plaza de la Encarnación) in the old quarter of Seville. The building was designed by German architect Jürgen Mayer, and construction was completed in April 2011. The 28-meter-high facility covers an area of 150 by 75 meters and claims to be the largest wooden structure in the world.

Hashtags

International Geographic

@internationalgeographic · Post #5459 · 28.02.2025 г., 00:07

Fuerteventure, #Spain🇪🇸 This wonderful natural pool is located on the island of Fuerteventure. 🏝 Interestingly, Fuertever is considered one of the oldest islands of Spain, formed thanks to the eruption of the volcano more than 20 million years ago. This fact confirms the unusual form of the island and the complete absence of snakes and insects dangerous for humans. Also, the pluses of this place should include an almost complete absence of rains and a soft climate.

Hashtags

POPULAR FRONT

@popularxfront · Post #4449 · 11.01.2026 г., 16:56

🇪🇸#Spain / Catalonia: There were intense clashes yesterday in Sentmenat (Barcelona) between anti-fascist protesters and riot police. Groups of demonstrators took to the streets to oppose the opening of a new delegation and headquarters by the neo-Nazi group Núcleo Nacional. Hundreds of anti-fascist activists gathered near the industrial area where the far-right group was holding an event, leading to police charges as officers attempted to prevent protesters from reaching the venue. (📹 via @rebonico on X)

Hashtags

POPULAR FRONT

@popularxfront · Post #4037 · 02.12.2025 г., 10:44

🇪🇸#Spain: Europol and the Spanish National Police have uncovered a far-right accelerationist cell linked to The Base. Three suspects were arrested during coordinated raids in Madrid, Valencia and Castellón, with officers seizing firearms, ammunition, knives, tactical gear, and accelerationist/neo-Nazi propaganda. According to investigators, the cell was "highly radicalised" and it had conducted paramilitary style training, while being allegedly in contact with The Base's founder, Rinaldo Nazzaro. Only a month ago, The Base issued messages on its Telegram channels urging the consolidation of its dispersed international cells. (via The Guardian)

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1414 · 08.05.2025 г., 12:14

🌍Alhambra in Spain✨ 📏 📏 📏 📏 📏 📏 📏 📏 ⭐ Alhambra, a stunning fortress-palace in Granada, is one of Spain’s most iconic landmarks, showcasing beautiful Islamic architecture. 📏 📏 📏 📏 📏 📏 📏 📏 #Spain🇪🇸@voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1211 · 27.12.2024 г., 13:14

😍When talking about Barcelona, one immediately thinks of the Sagrada Familia. 📏 📏 📏 📏 📏 📏 📏 📏 After 137 years, this landmark has become one of the most visited not only in Catalonia but in all of Europe. 🌟 📏 📏 📏 📏 📏 📏 📏 📏 #Spain🇪🇸 @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1209 · 25.12.2024 г., 13:14

🗺Spain 🇪🇸 📏 📏 📏 📏 📏 📏 📏 📏 Mount Tibidabo — the highest point in the Spanish city of Barcelona, part of the Collserola range. 📏 📏 📏 📏 📏 📏 📏 📏 🌟From this hill, you get a stunning panorama of the Catalonian capital, enjoyed by both tourists and locals. Though relatively low at just over 500 meters above sea level, both the mountain and its summit attractions are visible from anywhere in the city. 📏 📏 📏 📏 📏 📏 📏 📏 #Spain @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1194 · 13.12.2024 г., 13:14

November in Barcelona is pure magic ✨ 📏 📏 📏 📏 📏 📏 📏 📏 💚This area between Urquinaona Square and Paseo de San Juan Avenue is a treasure trove of architectural masterpieces! Every building here is a work of art, rich in history and unique charm. 📏 📏 📏 📏 📏 📏 📏 📏 💚Imagine walking down a narrow street, the autumn leaves rustling underfoot, with majestic buildings towering around you, adorned with elegant balconies and carved doors. Time seems to slow down, and you’re immersed in the atmosphere of old Barcelona. 📏 📏 📏 📏 📏 📏 📏 📏 #Spain🇪🇸 @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1025 · 14.07.2024 г., 12:14

Spain 🇪🇸 Mount Tibidabo — the highest point in the Spanish city of Barcelona, part of the Collserola range. From this hill, you get a stunning panorama of the Catalonian capital, enjoyed by both tourists and locals. Though relatively low at just over 500 meters above sea level, both the mountain and its summit attractions are visible from anywhere in the city. #Spain @voyage

Hashtags

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