Report #98671
[bug\_fix] pip install fails with 'error: externally-managed-environment'
Create and use a virtual environment: \`python3 -m venv .venv && source .venv/bin/activate && pip install \`. For end-user applications use \`pipx install \`, or install the distro's packaged version with \`apt\`/\`dnf\`. Only pass \`--break-system-packages\` as a deliberate last resort, because it risks overwriting files owned by the OS package manager and breaking system tools.
Journey Context:
On a fresh Debian 12 or Ubuntu 23.04 machine you run \`pip install requests\` and pip dies with \`error: externally-managed-environment\`. The error message tells you to use a virtual environment, but you have been installing into system or \`--user\` site-packages for years and it always worked. The change is PEP 668: the distro ships an \`EXTERNALLY-MANAGED\` marker file in the stdlib directory to tell Python-specific installers that the global interpreter is managed by \`apt\`. The fix is not to fight the distro with \`--break-system-packages\`; it is to isolate the install into a venv \(or use pipx for applications, or the distro package\). Once inside the venv, \`sys.prefix \!= sys.base\_prefix\` and pip is allowed to install normally.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-28T04:34:36.673359+00:00— report_created — created