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

Резултати

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

Пребарај: #raspberry

当前筛选 #raspberry清除筛选
Linuxgram 🐧

@linuxgram · Post #18754 · 12.05.2026 г., 08:32

📰 My Raspberry Pi 4 still has a job in my homelab, and it isn't Home Assistant I ran Home Assistant on a Raspberry Pi 4 for over a year. Though the Pi booted from an NVMe SSD, the Pi's 4GB memory limit became difficult to ignore as I built ESPHome devices. Recently, I moved Home Assistant to a mini PC and almost shelved the Pi, since it was just sitting in the corner doing nothing. 🔗 Source: https://www.xda-developers.com/raspberry-pi-4-homelab-without-home-assistant/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18710 · 08.05.2026 г., 10:51

📰 Your smart home needs both an ESP32 and Raspberry Pi 5, not one or the other For the past few months, I’ve been making the case for the ESP32. I'd argue that the $5 ESP32 microcontroller can easily replace the Raspberry Pi 5. That helps to save on cost and reduce the bulk. I still believe that. 🔗 Source: https://www.xda-developers.com/your-smart-home-needs-an-esp32-and-raspberry-pi/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18681 · 05.05.2026 г., 20:42

📰 Raspberry Pi Imager Now Supports Raspberry Pi Connect for Organizations Raspberry Pi Imager 2.0.9 flashing tool for Raspberry Pi devices is now available for download with support for Raspberry Pi Connect for Organizations and many other changes. 🔗 Source: https://9to5linux.com/raspberry-pi-imager-now-supports-raspberry-pi-connect-for-organizations #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18668 · 04.05.2026 г., 12:24

📰 Raspberry Pi 5's price hike pushed me toward mini PCs, and now I can't justify going back When Raspberry Pi 5 got a price hike, my first reaction was to pause and re-evaluate my plans. I’ve been running a Pi 4 as my home lab for years, and I've always wanted to upgrade to the Pi 5. After waiting for stock availability, I decided to take my requirements more seriously. 🔗 Source: https://www.xda-developers.com/raspberry-pi-5-price-hike-pushed-me-to-mini-pcs/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18660 · 03.05.2026 г., 07:31

📰 I replaced my Raspberry Pis with $5 ESP32s for smart home projects, and they do everything I need My smart home doesn't need a Raspberry Pi anymore, and the ESP32 just proved it. 🔗 Source: https://www.xda-developers.com/i-replaced-raspberry-pis-with-5-esp32s-for-home-assistant/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18639 · 01.05.2026 г., 07:59

📰 Running local AI on the Raspberry Pi 5 taught me why cloud models are still winning Except for Google's AI responses to searches, I've never used AI before, not once. Most people I know, when they hear this, say, "You haven't used AI? But it's so useful!" I disagreed; I'd seen the results Google's AI gave, and it honestly seemed overhyped. Then I thought about it and realized I couldn't really judge it without testing it. However, being into tech, I didn't want to risk my privacy, knowing the impact that can have, so I wanted... 🔗 Source: https://www.xda-developers.com/local-ai-raspberry-pi-5-positive-negative/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18570 · 25.04.2026 г., 20:47

📰 I turned a Raspberry Pi and mini PC into a portable homelab that fits in my backpack I love my homelab — but accessing it remotely from a hotel or café only gets me so far. That remote connection works fine for simpler tasks like checking dashboards, running scripts, waking up, or shutting down machines. But anything heavier — large file transfers, streaming, or running intensive workloads — quickly reveals public Wi-Fi’s limitations. 🔗 Source: https://www.xda-developers.com/turned-raspberry-pi-mini-pc-into-portable-homelab-that-fits-backpack/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18522 · 22.04.2026 г., 05:14

📰 Someone turned an ESP32 T-LoRa Pager into a portable music machine, and you can too While Raspberry Pis and ESP32s are great for hobbyists, they also regularly find themselves in products. They're very useful, after all, so it's only natural that companies will use them as their hardware of choice when making something small that doesn't need to be an absolute powerhouse. 🔗 Source: https://www.xda-developers.com/someone-turned-an-esp32-t-lora-pager-into-a-portable-music-machine-and-you-can-too/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18501 · 20.04.2026 г., 21:06

📰 I stopped trusting my router's diagnostics after my Raspberry Pi found what it missed Lately, I’ve been working on a lot of ESP32 projects, so I keep checking my router for connectivity. But those devices kept showing as connected even when powered off. That made me question whether my router was giving me the full picture. 🔗 Source: https://www.xda-developers.com/stopped-trusting-routers-diagnostics-after-raspberry-pi-found-what-missed/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18476 · 18.04.2026 г., 05:46

📰 My Raspberry Pi NAS taught me that cheap storage isn't worth the compromise A NAS without dependable storage is just a very patient disappointment. 🔗 Source: https://www.xda-developers.com/raspberry-pi-nas-taught-cheap-storage-isnt-worth-compromise/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18455 · 16.04.2026 г., 07:46

📰 Travel computing doesn't need a laptop — the Raspberry Pi 5 proved that to me For the right traveler, the Raspberry Pi 5 is more than just adequate on the road. 🔗 Source: https://www.xda-developers.com/travel-computing-doesnt-need-laptop-raspberry-pi-5-proved/ #raspberry

Hashtags

Linuxgram 🐧

@linuxgram · Post #18445 · 15.04.2026 г., 12:18

📰Raspberry Pi OS ends open-door policy for sudo Command prefix will require password by default The latest version of Raspberry Pi OS now requires a password for sudo by default.… 🔗 Source: https://go.theregister.com/feed/www.theregister.com/2026/04/15/raspberry_pi_os_sudo/ #raspberry

Hashtags

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