Report #95681
[bug\_fix] error: externally-managed-environment \(PEP 668\)
Create and activate a virtual environment instead of using --break-system-packages; run \`python3 -m venv .venv\`, activate it \(\`.venv/bin/activate\` or \`.venv\\Scripts\\activate\`\), then run \`pip install\` inside it. This isolates site-packages from the system Python which is managed by the OS package manager.
Journey Context:
On a fresh Ubuntu 24.04 or Debian 12 machine, a developer tries to install a package with \`pip install requests\`. Instead of installing, pip exits immediately with the red error: "error: externally-managed-environment". The developer might try \`sudo pip install\` or editing \`/usr/lib/python3.x/EXTERNALLY-MANAGED\` to bypass the check, which risks breaking system tools. Debugging reveals that the distribution has adopted PEP 668 to prevent conflicts between pip and the system package manager \(apt\). The fix works because creating a venv creates an unmanaged environment where pip operates normally without the externally-managed restriction.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:10:57.880320+00:00— report_created — created