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

Резултати

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

Пребарај: #children

当前筛选 #children清除筛选
RTDocumentary

@rtdocumentary · Post #892 · 09.06.2022 г., 16:01

‘Jorge was my only son, he meant everything to me. He and his pregnant wife were taken from their home in handcuffs with bags over their heads.’ Delia de Califano from Argentina has never seen her son or daughter-in-law after the event she describes. From 1976 to 1983 Argentina was ruled by the junta. Those who disagreed with the military dictatorship were kidnapped and tortured. Children of opposition members were given away to childless military families. For more than 30 years Delia hasn’t lost hope to find her grandson. Those women, whose kids were kidnapped back then created a group and became known as mothers of the Plaza de Mayo. Mostly being 80+, they are still looking for their children. Their stories are in the documentary Argentina’s Stolen Children. #humanstories#children Follow: https://t.me/rtdocumentary

RTDocumentary

@rtdocumentary · Post #920 · 14.06.2022 г., 10:26

How Ukrainian schoolchildren are instilled with Nazi ideology A textbook titled 'Defence of the Motherland' was found in one of the schools in Mariupol. It was published in 2018 under the patronage of the SBU and was given to high school students. The textbook describes the mining of public places, biological weapons, and how to handle grenades, RPGs and Kalashnikovs. The book also explains to teenagers the advantages of NATO and how dangerous Russia is for Ukraine. Several chapters are devoted to warfare. Teenagers were told how to fire, act as part of a combat team and provide first aid if wounded during a fight. In addition, illustrations explain how NATO troops defend and attack. And that’s not all there is to say about education in Ukraine. See our documentary film Fast Forward to Fascism to find out how children are being taught a distorted version of history. #Donbass#history#children Follow: https://t.me/rtdocumentary

RTDocumentary

@rtdocumentary · Post #906 · 11.06.2022 г., 12:01

According to the deputy regional director of UNICEF, Rania Dagash, 386,000 children in Somalia need treatment due to malnutrition caused by a long drought and the lack of humanitarian aid. Experts say the COVID-19 pandemic and anti-Russian sanctions have caused difficulties in helping people. For example, about 92% of Somalia’s wheat needs came from Ukraine and Russia, but now supply chains are disrupted, said Rania Dagash. But the main reason is drought linked with global climate change. Today’s most suffer from freshwater shortages, and more frequent droughts regions are Somalia, Ethiopia and Kenya. Droughts are just a part of a global water crisis. Watch the documentary No Way Back: Water to learn more about what’s happening to the water cycle and our planet’s water resources. #children#Somalia Follow: https://t.me/rtdocumentary

RTDocumentary

@rtdocumentary · Post #816 · 25.05.2022 г., 17:02

‘I told them it isn’t for me, but they didn’t believe me. They kept beating me. They fed me very poorly.’ This Indian girl was held as a sex slave for a year. She left home to get some money for her brothers to get an education, but it ended badly for her. In India, these kinds of stories are common. Children are often kidnapped and sold into slavery. Today is International Missing Children’s Day, that’s why we want to show you this poor Indian girl’s story. Watch the clip to know what horror she has gone through. Find more stories like this in the documentary Lost Kids. #children#slavery Follow: https://t.me/rtdocumentary

America 🇺🇸 News & Politics

@America · Post #10630 · 09.05.2026 г., 00:05

📱🚫FLORIDA BANS SOCIAL MEDIA FOR KIDS UNDER 16 — PARENTS REVOLT 🔹 Governor DeSantis signs strictest social media law in America — platforms must verify age or face fifty thousand fines per violation 💰 🔹 TikTok, Instagram, Snapchat given 90 days to implement age verification — biometric scanning and ID checks required 📋 🔹 Parents file federal lawsuit claiming violation of First Amendment rights — ACLU joins challenge citing free speech 📊 🔹 Tech industry threatens to exit Florida market over compliance costs — Meta considers blocking state IP addresses 🔥 America's kids vs. Big Tech battle intensifies as states push digital protection laws 💻 #Florida#socialmedia#children @america

Borkena

@borkena · Post #6206 · 23.04.2026 г., 14:19

"ሂውማን ራይትስ ዋች" በወልቃይት በትግራይ ተወላጆች ላይ መድሎ ይደረጋል የሚል ክስ አሰማ ፤ በሰሜኑ ጦርነት ከ 30,000 በላይ ህጻናት ወላጂ አልባ ሆነዋል መባሉ እና ሌሎች ዜናዎች፡፡ https://youtu.be/LxMt8G6OnbY#Ethiopia#News#EthiopianNews#Welkait#Tigray#Children

ПретходнаСтраница 1 од 4Следна