PlainError

pip: error: externally-managed-environment

Updated 2026-11-20 · 5 fixes · expanded guide with sources · how we write fixes

TL;DRThis pip error means your operating system manages this Python install (Debian 12, Ubuntu 23.04+, Fedora, Homebrew, Arch and others) and refuses pip installs into it, so pip cannot break system tools. Install into a virtual environment, use pipx for command-line apps, or use the system package manager.

Most likely cause: Running pip install against the system Python on a distro that ships an EXTERNALLY-MANAGED marker (PEP 668)

Try first: Create a virtual environment (recommended) (python3 -m venv .venv && . .venv/bin/activate && pip install requests)

Likely causes

  1. Running pip install against the system Python on a distro that ships an EXTERNALLY-MANAGED marker (PEP 668)most likely
  2. Homebrew's Python on macOS, which also marks itself externally managedpossible
  3. A script or Dockerfile written before the change that installs globally with pipless likely

Why this happens

Linux distributions use Python for their own tools, such as apt helpers and system scripts. When pip installs or upgrades a package globally, it can replace a version those tools depend on and break the system. PEP 668 lets a distro put an EXTERNALLY-MANAGED file next to its Python's standard library; pip 23+ sees it and refuses global installs with this error. Nothing is broken; pip is protecting the system install.

Which option to use

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Create a virtual environment (recommended)Safe

    In your project folder, create and activate a venv, then pip works normally inside it. On Debian/Ubuntu you may need sudo apt install python3-venv first.

    python3 -m venv .venv && . .venv/bin/activate && pip install requests
  2. Use pipx for command-line toolsChanges settings

    For apps like black, httpie or yt-dlp, pipx gives each its own environment and puts the command on your PATH.

    sudo apt install pipx && pipx ensurepath && pipx install black
  3. Use the system package if one existsChanges settings

    Many libraries are packaged by the distro, e.g. sudo apt install python3-requests. These are tested with the system Python.

    sudo apt install python3-requests
  4. In Docker, use a venv or the official python imageChanges settings

    The official python:3.x images are not externally managed. On distro images, create a venv in the Dockerfile and put it first on PATH.

  5. Install for your user only (last resort)Dangerous

    pip install --user --break-system-packages <pkg> installs into ~/.local. It can still conflict with system packages, so prefer a venv.

    pip install --user --break-system-packages requests

    ⚠ This can break distro tools that rely on specific package versions. Back up or snapshot important systems first, and prefer a virtual environment.

If that didn't fix it

If pip still errors inside an activated venv, check `which pip` points into .venv; if not, run `python -m pip install ...` instead.

When to see a technician

No technician needed. On a managed server, ask the administrator which Python environment you should use.

Questions people ask

Can I just delete the EXTERNALLY-MANAGED file?
You can, but it removes the protection for everything on the system and comes back with the next Python package update. A virtual environment is safer and just as quick.
Does this affect Windows?
No. The python.org Windows installer is not externally managed. You will see this on Linux distributions and Homebrew Python.

Sources

Did this fix it? Report a problem

Related errors

All Coding errors →