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

Резултати

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

Пребарај: #tanzania

当前筛选 #tanzania清除筛选
Voyage.Travel.Tourism

@VOYAGE · Post #1402 · 26.04.2025 г., 12:14

🌴💖Zanzibar – the pearl of Tanzania and one of the best beach destinations in the Indian Ocean 📏 📏 📏 📏 📏 📏 📏 📏 #Tanzania🇹🇿@voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1189 · 08.12.2024 г., 13:14

Zanzibar – The Jewel of Tanzania and one of the best beach destinations in the Indian Ocean. 🌴💖 📏 📏 📏 📏 📏 📏 📏 📏 #Tanzania🇹🇿 @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1079 · 31.08.2024 г., 12:14

🗺Tanzania🇹🇿 Zanzibar is Africa's Maldives, a place on the map with dozens of breathtakingly beautiful beaches! Pristine white sand, turquoise Indian Ocean waters, gentle sunshine, and fewer crowds make it an ideal vacation spot. #Tanzania @voyage

Hashtags

RTDocumentary

@rtdocumentary · Post #215 · 16.09.2021 г., 11:45

Crawling up Kilimanjaro with no legs #video#Tanzania When Aleksandr was born with no legs and deformed fingers, his mother abandoned him. He grew up in an orphanage for kids with disabilities in a remote Russian town. However, Aleksandr has always aimed high and dreamed big. Aleksandr got lucky and was selected to take part in a US humanitarian project. At the age of 15, he walked on his new prostheses for the first time in his life. His temporary foster parents couldn’t let him go and adopted Aleksandr. To inspire kids with disabilities, Aleksandr and his friends from the orphanage took on the challenge to climb Africa’s highest mountain Mount Kilimanjaro at 5,895 metres. RT Documentary witnessed their incredible feat and made a film - https://youtu.be/v2Sz3k9gKp8 For now, Aleksandr lives and studies in Boston, USA, and has climbed Kilimanjaro for a second time! Follow: https://t.me/rtdocumentary

ጠቅላይ ሚኒስትር ዐቢይ አሕመድ (ዶ/ር) ከታንዛኒያ ዩናይትድ ሪፐብሊክ ፕሬዝዳንት ጋር ተወያዩ ******************* ጠቅላይ ሚኒስትር ዐቢይ አሕመድ (ዶ/ር) ከታንዛኒያ ዩናይትድ ሪፐብሊክ ፕሬዝዳንት ሳሚያ ሱሉህ ሀሰን ጋር ተወያይተዋል፡፡ ጠቅላይ ሚኒስትሩ በማህበራዊ ትስሰር ገጻቸው ባጋሩት መልእክት፤ ከታንዛኒያ ዩናይትድ ሪፐብሊክ ፕሬዝዳንት ሳሚያ ሱሉህ ሀሰን ጋር የሁለትዮሽ ግንኙነትን በሚያጠናክሩ አስቻይ ጉዳዮች ላይ ውይይት አድርገናል ብለዋል:: #EthiopianBroadcastingCorporation#Ebcdotstream#Ethiopia#PMAbiy#Tanzania#Diplomacy

RTDocumentary

@rtdocumentary · Post #770 · 15.05.2022 г., 18:02

‘Isaac is a very fast and intelligent rat. He is good at concentrating on finding TNT.’ In Tanzania, giant hamster rats are trained to be professional bomb disposal experts. They work in minefields in former hotspots. The rodents can easily smell carefully camouflaged explosive devices thanks to their excellent sense of smell. Do you want to see how a bomb-sniffing rat is trained? Then, watch the clip and film Isaac: The Story of a Little Giant. #Tanzania#minefields Follow: https://t.me/rtdocumentary

AREA

@area_eng · Post #115 · 22.06.2025 г., 14:03

Russia and Tanzania are developing cooperation in nuclear energy During the negotiations at SPIEF-2025, Russian Energy Minister Sergei Tsivilev and Tanzanian Deputy Prime Minister and Minister of Energy Biteko Doto Mashaka discussed the prospects for joint work in the energy sector. The Tanzanian side presented an ambitious five-year energy development program, which provides for a gradual increase in electricity supply to the population from current levels to 75%, and in the future - up to 100% coverage. Particular attention in the strategy is paid to the development of renewable energy sources and the study of the possibilities of peaceful nuclear energy. "Our president set the task that it is impossible to build technological sovereignty in one separate country. It must be built together with friendly countries. And the Republic of Tanzania is precisely our friendly country. Therefore, we are ready to share our technologies," Sergei Tsivilev emphasized. The Russian side proposed a comprehensive approach to cooperation. It includes the possible construction of low-power nuclear power plants, training of personnel in Russian universities, conducting technical and economic research, as well as implementing joint projects in non-energy areas - medicine and agriculture. This dialogue has become a logical continuation of previously reached agreements. In April 2025, Rosatom and the Ministry of Energy of Tanzania signed a memorandum on cooperation in the field of non-energy application of nuclear technologies. New negotiations expand the scope of interaction, opening up prospects for the implementation of large-scale energy projects. Experts note that Russian-Tanzanian cooperation in the nuclear sector can become a key factor in the implementation of the energy strategy of the African country. It will provide its population with stable and environmentally friendly energy sources, and will also create a basis for the technological development of a number of related sectors of the economy. #AREA#Africa#Russia#Tanzania#energy

RTDocumentary

@rtdocumentary · Post #749 · 12.05.2022 г., 15:00

'My father needed cows, not me'. These are the words of 13-year-old Kristina from Tanzania. Her father sold her to an older man to get a cow. The tradition is still widespread in Tanzania. Families live in poverty and find it difficult to feed themselves. So for a 13-year–old bride, her parents receive a rich dowry - almost a herd of cows. But the Tanzanian government is cracking down on this custom. Watch Kristina’s heartbreaking story. You can learn more about this tradition in ourfilm Bride Trade. #Tanzania#traditions#bridetrade Follow: https://t.me/rtdocumentary

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