From martin.weis.newsadress at gmx.de Tue Dec 10 15:44:49 2024 From: martin.weis.newsadress at gmx.de (Martin Weis) Date: Wed, 11 Dec 2024 00:44:49 +0100 Subject: [Ubuntu] Python environment for QGIS (externally-managed-environment) Message-ID: Dear list, I am currently not sure how to properly handle the `externally-managed-environment` python installation for QGIS plugins (and other software). pip is now actively discouraged to install system-wide or per user - for good reasons, but solved some dependencies easily for me. Basically it would make sense to have a venv defined for QGIS, where pip can install packages. Not all dependencies can be found/installed via apt, some packages even may need special version pinning. Is there a recommended way to define and start such an environment for QGIS? Having a simple wrapper script might do for my own use case, but can such an environment be defined/integrated/deployed properly and used at startup? This ancient SE question is about it https://gis.stackexchange.com/questions/131932/starting-qgis-with-virtualenv-python and here is a working helper script to create a QGIS python environment: https://github.com/GispoCoding/qgis-venv-creator Thank you for your work and input! Martin > $ pip install > error: externally-managed-environment > > ? This environment is externally managed > ??> To install Python packages system-wide, try apt install > python3-xyz, where xyz is the package you are trying to > install. > > If you wish to install a non-Debian-packaged Python package, > create a virtual environment using python3 -m venv path/to/venv. > Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make > sure you have python3-full installed. > > If you wish to install a non-Debian packaged Python application, > it may be easiest to use pipx install xyz, which will manage a > virtual environment for you. Make sure you have pipx installed. > > See /usr/share/doc/python3.12/README.venv for more information. > > [...] > note: If you believe this is a mistake, please contact your Python > installation or OS distribution provider. You can override this, at the > risk of breaking your Python installation or OS, by passing --break- > system-packages. > hint: See PEP 668 for the detailed specification.