Search notes:

PEP 668 - Marking Python base environments as “externally managed”

PEP 668 discuses the problems that can arise when multiple installers operate on the same Python installation.
This PEP is a historical document - the up-to-date canonical spec is Externally Managed Environments.

TODO

Debian

Debian declares its Python install to be externally managed.
Thus, pip (and other installers) will refuse to install packages system-wide.
pip allows to install packages only
  • to virtual environments
  • to separate Python installations
  • when the --break-system-packages option is used (this option is not available in pip but must be stated with sudo python3 -m pip install --break-system-packages …)
  • by setting the environment variable PIP_BREAK_SYSTEM_PACKAGES to 1 and exporting it
  • adding the option break-system-packages = true under the [global] section in ~/.config/pip/pip.conf or /etc/pip.conf.
  • Removing /usr/lib/python3.x/EXTERNALLY-MANAGED
In Debian:
$ sudo python 3 -m pip install -U yt-dlp

× 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.11/README.venv for more information.

See also

A small list of other interesting PEPs

Links

https://peps.python.org/pep-0668

Index