Что делать если нужно поставить какую-то 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
⚡️swap.coffee: Major UI Widget Kit Update
#update#documentation
swap.coffee has introduced a significant update to its UI Widget Kit. The update features a new design, supports MEV Protect, Limit Orders, DCA, and much more. Updated documentation is now available for users at @swapcoffee_dev_chat.
Source: link
@tonlines
Cekura Secures $500K Funding
Cekura has completed a funding round of $500K on December 4, 2024. The company specializes in browser agents that ensure product documentation remains current.
#Cekura#Funding#Documentation#Tech#BrowserAgents#Startup#Investment #2024 #Innovation#Business
Documentation News:
In Moscow, two men who failed to register for military service were stripped of their citizenship
This was reported on the Telegram channel by the official representative of the Russian Ministry of Internal Affairs Irina Volk.
Volk recalled that, in accordance with Russian law, every man with acquired citizenship must register for military service within two weeks. Violators face punishment.
Our advise to members:
1. Comply with local laws. Register for military service if you are of draft age and have acquired citizenship.
2. Similarly, if you are of draft age and have no plans to register for military service, then you should consider not applying for citizenship.
Like the popular saying goes, you can't eat your cake and have it.
https://t.me/nido_russia/1827
#laws#naturaliation#documentation#passport#citizenship
Source: Life(.ru)
#html#documentation#hacktoberfest#hass#hassio#home_assistant#jekyll
You can set up and contribute to the Home Assistant website easily by following the developer documentation, which explains how to edit and preview the site locally using simple commands. This helps you see your changes live on your computer before sharing them. There are also tools to speed up website updates by temporarily hiding blog posts you’re not working on, making the process faster. This setup benefits you by making it straightforward to improve the site, test changes quickly, and manage content efficiently without delays. It’s designed to support smooth collaboration and faster website maintenance.
https://github.com/home-assistant/home-assistant.io
#python#documentation#gotchas#interview_questions#pitfalls#python#python_interview_questions#snippets#wats#wtf
Python is a high-level, easy-to-read programming language widely used in many fields like web development, data science, and AI. The "What the f*ck Python?" project helps you understand tricky, surprising Python behaviors through clear examples and explanations. It reveals lesser-known features and common pitfalls, making it easier to write better code and debug problems. By exploring these examples, you can deepen your knowledge of Python’s internals, improve your coding skills, and avoid common mistakes, which benefits both beginners and experienced programmers alike[3].
https://github.com/satwikkansal/wtfpython
#ruby#api_documentation#app#devdocs#developer_tools#docs#documentation#documentation_tool#hacktoberfest#offline#pwa
DevDocs is a free, fast, and easy-to-use web app that lets you quickly search and browse official API documentation for many programming languages and tools all in one place. It works offline, has a clean interface, supports keyboard shortcuts, dark mode, and mobile use. You can access over 100 documentations like HTML, CSS, JavaScript, and more without switching tabs or searching Google repeatedly. It saves time by providing instant search results and keeps everything organized, making coding and learning more efficient and enjoyable. You can use it online or run it locally with Docker for even faster access[1][2][3][5].
https://github.com/freeCodeCamp/devdocs
— LibreCellular 21.04 documentation –https://librecellular.org/
The LibreCellular project aims to make it easier to create #4G cellular #networks with open source software and low cost software-defined radio (#SDR) hardware. Seeking to achieve this via validated hardware and software configurations that are subjected to rigorous testing, together with additional tooling and #documentation for repeatable deployment.
LibreCellular will build on the work of numerous existing open source software and hardware projects, related to both the #cellular platform itself and associated test #infrastructure. Where necessary additional components will be developed, with any software source code and #hardware designs published under #opensource licences. The focus is very much on integration, testing, packaging and documentation, reusing and building upon existing solutions..
#LibreCellular#CellulaireLibre
#python#ai#ai_agents#ai_coding#claude_code_plugin#claude_code_plugins#claude_code_plugins_marketplace#claude_marketplace#claude_plugin#claude_skills#docs#documentation#mcp#mcp_server#postgres#postgresql#skills
pg-aiguide helps AI coding tools create better PostgreSQL code with semantic search of official docs, best-practice skills for schemas/indexes, and extension info like TimescaleDB. Install it free as a public MCP server or Claude plugin in tools like Cursor/VS Code for one-click setup. It fixes AI's weak spots—outdated code, missing constraints (4x more), indexes (55% more), and modern PG17 features—producing robust, fast, maintainable schemas that save you debugging time and production fixes.
https://github.com/timescale/pg-aiguide
#python#blocknotejs#collaborative#django#documentation#g2g#government#knowledge#knowledge_base#mit#mit_license#opensource#reactjs#realtime_collaboration#self_hosted#wiki#yjs
Docs is a collaborative online text editor that helps you and your team write, edit, and organize documents together in real time, even offline. It offers easy formatting, AI tools like summarizing and rephrasing, and secure sharing with controlled access. You can export documents in various formats and create structured knowledge with subpages. Docs is open source, easy to self-host, and used by public organizations, ensuring your data stays secure and private. This tool saves time, improves teamwork, and turns your notes into organized knowledge you can access anytime. It’s great for teams wanting efficient, secure, and collaborative document editing.
https://github.com/suitenumerique/docs