Что делать если нужно поставить какую-то 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
Released in North America on 29th November 1972 by Atari, Pong was one of the earliest video games. The game became popular both at home on consoles and at video arcades.
[Play it here] [read more]
Send your high-scores in the comments. 😉
@googlefactss
#pong#games#computer
New update available!
Nothing Phone (2)
Version: Pong-B4.0-251119-1654
⬇️OTA & Factory Images
🧑💻Installation Guide
📔 Changelogs:
You’re now upgrading to the official release of Nothing OS 4.0, powered by Android 16. Please back up your user data (photos, call logs, contacts, etc.) before proceeding with the upgrade. Take a look at what's included in this update:
New Features
🕶 Hiding apps directly from the home screen and App drawer is now supported. Find hidden apps via: Home screen > App drawer > Hidden icons.
🔍 Managing the search scope is now supported in App drawer to display results within a specific scope.
📏 Added more size options for Weather, Pedometer, Screen Time widgets.
↔️ 2x2 size is now supported for most QuickSettings tiles.
🟢 Pop-up view now supports two floating icons for easier switching.
⚡️ System upgrade supports app optimisation to improve startup speed. Path: Settings > Apps > App optimisation.
Essential Innovations
🛝 Introducing Playground (Alpha) — come to experience unique creations from the Community, including Essential Apps, Camera Presets, and EQ Profiles.
🪀 Essential Apps (Alpha) are now open for download. Enjoy the AI-powered, community-crafted apps that blend creativity with efficiency.
Notes:
For more details of Playground & Essential Apps, please visit https://playground.nothing.tech.
Visual Enhancements
🌠 Nothing app icons have been redesigned with an all-new, fresh look.
📶 Updated status bar icons with a more intuitive look.
🎴 Updated the lock screen password page with wallpaper blur effect.
⏱️ Added 2 new lock screen clock faces in Customisation.
🌑 Extra dark mode is now available, bringing a more immersive dark style. Path: Settings > Display > Dark theme > Extra dark mode.
🌌 Improved transition animations in certain scenarios for a smoother, more fluid experience.
Glyph Interface
🤫 Added a setting to choose whether Flip to Glyph switches your phone to Silent or Vibrate mode.
💡 Glyph Progress now uses Android 16 Live Update notifications for improved compatibility with third-party apps.
Camera Enhancements
🎛 Presets: Updated default list with new popular styles.
🎨 Filters: Added intensity adjustment and exclusive 'Stretch' styles.
🎞 Motion Photos: Supports longer recording times and audio capture.
🖼 Watermarks: Introduced new Nothing brand watermarks and artistic frames.
📱 Interface: Refreshed camera UI design with optimised interactions.
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
🫂 Community: @Nothing_Archive
#Pong#OTA
New update available!
Nothing Phone (2)
Version: Pong-V3.2-250828-1921
⬇️OTA & Factory Images
🧑💻Installation Guide
📔 Changelogs:
New Features:
📷Preset is now available in the Camera app settings.
🎨 Introduced the new “Stretch” preset, created in collaboration with photographer Jordan Hemingway. The preset features rich shadows and extended highlights for unique results. (Missing)
✅ Default gallery options for previewing photos in Camera app settings are updated.
🚶 Pedometer and Screentime Widgets now support sharing.
📱 Shared Widgets now support more sticker types.
General Improvements and Bug Fixes:
🔧 Fixed tiles display errors in Quick Settings.
🗃 Resolved the issue of failing to open PDFs in Cloned apps.
📊 Optimised the display of VoNR icon in the status bar.
⛔️ Fixed the issue of failing to block connected devices in Hotspot and tethering.
🔋 Optimised battery usage when connecting watches to the phone.
🔤 Fixed Inter font display issues in Instagram, Subito and other apps.
⚙️ Enhanced system stability and improved network connection.
🛡 Updated to the September security patch.
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
🫂 Community: @Nothing_Archive
#Pong#OTA
New update available!
Nothing Phone (2)
Version: Pong-V3.2-250708-2227
⬇️Incremental & OTA Images
🧑💻Installation Guide
📔 Changelogs:
New Feature
📶 Hotspot Manager: Easily manage devices connected to your hotspot.
General Improvements and Bug Fixes
🖼 Fixed rare issue causing the Gallery to crash when opening videos.
📱 Fixed issues where the apps’ UIs sometimes displayed incorrectly in certain situations.
🛡 Updated to Android security patch for June.
🔧 Enhanced overall system stability.
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
🫂 Community: @Nothing_Archive
#Pong#OTA
New update available!
Nothing Phone (2)
Version: Pong-V3.0-250304-1717
OTA Size: 78.8 MB
⬇️Incremental & OTA Images
🧑💻Installation Guide
📔 Changelogs:
🔒 Introduced Power off verify. You can now enable a security check before your phone shuts down when locked. Go to Settings > Security and privacy > More security and privacy > Power off verify.
🖼 Updated the design of title bar in the pop-up view, for a cleaner and more intuitive look.
🛡 Updated to the latest March 2025 security patch for improved protection.
Bug fixes & stability improvements:
📡 Enhanced stability for network and bluetooth connections, ensuring a more reliable experience.
📷 Resolved certain issues to improve camera performance.
🔧 Fixed several issues affecting overall system stability.
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
🫂 Community: @Nothing_Archive
#Pong#OTA
New update available!
Nothing Phone (2)
Version: Pong-V3.0-250113-1723
OTA Size: 171.2 MB
⬇️Incremental & OTA Images
🧑💻Installation Guide
📔 Changelogs:
General Improvements
🔦 You can now long-press the Torch tile in Quick Settings to activate the Glyph torch.
📶 Optimised network selection to improve connection stability.
📱 Enhanced response speed for pulling down Quick Settings in landscape mode.
🛡 Updated security patch to 2025-01.
Bug fixes
💡 Fixed abnormal Glyph effects in specific scenarios.
🎧 Fixed issues with connected earbuds for better performance and stability.
🔧 Resolved system stability for a more reliable experience.
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
🫂 Community: @Nothing_Archive
#Pong#OTA