Report #14182
[bug\_fix] error: externally-managed-environment
Create and activate a virtual environment \(\`python3 -m venv .venv && source .venv/bin/activate\`\) and run pip inside it, or use the \`--break-system-packages\` flag \(strongly discouraged for production\).
Journey Context:
Developer sets up a fresh Ubuntu 24.04 VM or uses Debian 12. They run \`sudo pip install requests\` or \`pip install requests\` against the system Python. Pip 23.0\+ detects the \`EXTERNALLY-MANAGED\` marker file in \`/usr/lib/python3.x/dist-packages/\` placed by distro maintainers as per PEP 668. This mechanism prevents pip from clobbering system packages managed by apt, which could break OS tools like \`certbot\` or \`cloud-init\`. The developer tries \`sudo pip\` or \`pip --user\` but still hits the error. The correct resolution is to create a venv: \`python3 -m venv myenv\`, activate it, then pip install inside. This isolates the package set from the externally managed system environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:50:15.158341+00:00— report_created — created