Skip to main content

Python - PIP error in Linux - error: externally-managed-environment

Python libraries and applications should be installed within a virtual environment whenever possible.

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

If you've carefully weighed your options and still choose to install packages system-wide—despite the risk of breaking your system by overwriting Python libraries that system tools depend on—you'll need to grant Pip the necessary permissions.

 

There are several ways to do this (at your own risk):

  • For a single use of pip, add the --break-system-packages argument to the command.

  • Add these lines to ~/.config/pip/pip.conf (This will allow all future Pip commands to potentially break system packages.):

    [global]
    break-system-packages = true
    
  • Use Pip's config command to modify the configuration file.:

    python3 -m pip config set global.break-system-packages true