-->

DEVOPSZONES

  • Recent blogs

    error-externally-managed-environment-every-time-i-use-pip-3

     The proper way to install Python libraries and applications is to install them in a Python virtual environment whenever possible (the exceptions to this rule are quite rare).

    As indicated in the error message, there are two commons solutions to achieve this. Either by using a tool that creates a virtual environment for you or by creating a virtual environment directly yourself.

    If what you are trying to install is an application then a strong recommendation is to use a tool like pipx. pipx is available for installation as system package on Debian systems and Debian-based systems such as 

    Ubuntu:

    apt install pipx
    pipx install some-python-application
    

    To create a virtual environment yourself you can use Python's venv:

    python -m venv my-venv
    my-venv/bin/pip install some-python-library
    

    But if you still decide that you really want to install packages "system-wide" and risk breaking your system, then there are a couple of solutions:

    • use pip's argument --break-system-packages,
    • add following lines to ~/.config/pip/pip.conf:
    [global]
    break-system-packages = true

    No comments