Report #84958
[bug\_fix] error: externally-managed-environment
Do not use \`sudo pip install\`. Instead, create a virtual environment \(\`python3 -m venv env && source env/bin/activate && pip install ...\`\) or use \`pip install --user\` \(though venv is preferred\). If the warning is a false positive \(e.g., in a container where you manage the system Python\), set the environment variable \`PIP\_BREAK\_SYSTEM\_PACKAGES=1\` or pass \`--break-system-packages\` \(use with extreme caution\).
Journey Context:
A developer on Ubuntu 23.10 runs \`sudo pip install requests\` to get a quick utility. Instead of installing, pip errors out with "externally-managed-environment". They check \`/usr/lib/python3.x/EXTERNALLY-MANAGED\` and see the marker file added by PEP 668. They realize the system Python is reserved for the OS package manager \(apt\). They create a venv instead: \`python3 -m venv myenv && source myenv/bin/activate && pip install requests\`. It works. Root cause: PEP 668 allows distributions to mark their Python as externally managed, preventing pip from modifying it to avoid breaking system tools that depend on specific package versions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:11:13.284335+00:00— report_created — created