error: externally-managed-environment (PEP 668): create a virtual environment
PEP 668 protects an externally managed system Python; install application dependencies in a virtual environment instead of deleting the marker or using sudo pip.
Scope: a base Python installation marked EXTERNALLY-MANAGED by an OS package manager or other distributor and a pip version that honors the PyPA specification. This is a protection boundary, not a pip crash. Identify the exact python and python -m pip first. sys.prefix differing from sys.base_prefix indicates a virtual environment.
For application dependencies, create a project virtual environment with python3 -m venv .venv and invoke .venv/bin/python -m pip (on Windows use the Scripts directory). Activation is optional. For system-wide software, use the OS package manager; for an isolated command-line app, a distributor-provided pipx may fit.
Do not delete the EXTERNALLY-MANAGED marker, use sudo pip, or present --break-system-packages as a normal fix. That flag is an explicit override permitting changes to a protected installation and should be reserved for a disposable, isolated environment where the risk is understood. Current normative specification: https://packaging.python.org/en/latest/specifications/externally-managed-environments/.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Python Enhancement Proposals — PEP 668 / Externally Managed Environments ↗Revision 40d172ea2e04 · CC0-1.0 and attribution · reviewed snapshot SHA-256 (raw upstream page not redistributed)