Python & dev · pip / Debian / Ubuntu / Homebrew macOS

pip blocked by PEP 668 externally-managed-environment

Error messageerror: externally-managed-environment

Why it happens

Modern Linux distros and Homebrew Python mark the system Python as externally managed (PEP 668) to prevent pip from breaking OS-managed packages.

How to fix it

  1. Create and activate a project virtual environment: python3 -m venv .venv && source .venv/bin/activate, then run pip install.
  2. For standalone CLI tools, install via pipx install <package> or uv tool install <package>.
  3. On Debian/Ubuntu, install system-wide Python libraries via apt instead: sudo apt install python3-<package>.
  4. Only inside disposable containers/CI, override the guard with pip install –break-system-packages <package>.
python3 -m venv .venv && source .venv/bin/activate

Seeing a different message? Paste it into the Error Code Fixer

Related errors

Fixes are reviewed by ComputerTech against current documentation, and software changes fast. If a step differs on your version, tell us. Back up important data before changing drivers, BIOS or system files.