Report #42399
[bug\_fix] error: externally-managed-environment \(PEP 668\)
Create and use a virtual environment \(\`python3 -m venv .venv && source .venv/bin/activate\`\) and install packages there, or use \`pip install --user\` for user-local installs if permitted. The root cause is that modern distributions \(Ubuntu 22.04\+, Debian 12\+, Fedora\) mark the system Python as externally managed by the OS package manager \(apt/dnf\) to prevent pip from breaking system tools that depend on specific Python package versions.
Journey Context:
A developer spins up a new Ubuntu 22.04 LTS server or Docker container. They run \`pip install requests\` to get started. Instead of installing, pip throws \`error: externally-managed-environment\` with a message suggesting to use \`apt install python3-requests\` or create a venv. The developer tries \`sudo pip install requests\`, getting the same error. They search the error and find suggestions to use \`--break-system-packages\`, which works but feels wrong. They realize that the system Python is reserved for OS utilities \(like \`ubuntu-report\`, \`landscape-client\`\) that depend on specific library versions \(e.g., \`cryptography\`\). Installing via pip could upgrade or break these dependencies. The fix creates an isolated environment where pip has full control without affecting the system Python, which is the intended workflow for application development.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:38:23.936494+00:00— report_created — created