Report #101468
[bug\_fix] error: externally-managed-environment when running pip install globally on Debian/Ubuntu/Fedora/Homebrew Python
Create a project virtual environment and install inside it: \`python3 -m venv .venv && source .venv/bin/activate && python -m pip install ...\`. For standalone CLI tools use \`pipx install ...\`. Only use \`pip install --break-system-packages ...\` when the Python installation is truly disposable \(e.g., a CI/container image that is rebuilt from scratch\).
Journey Context:
On a fresh Ubuntu 24.04 machine you run \`pip install requests\` and immediately get 'error: externally-managed-environment'. You try \`sudo pip install\` and the same error appears. The rabbit-hole: modern Linux distros and Homebrew place an \`EXTERNALLY-MANAGED\` marker file in the interpreter's stdlib directory \(PEP 668\) to stop pip from writing into the system Python and breaking OS tools. The error is intentional, not a bug. The real fix is isolation: a venv gives pip its own site-packages, so the marker no longer applies. \`pipx\` does the same for CLI applications. \`--break-system-packages\` bypasses the check but should be reserved for containers because it risks collisions with distro packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:54:16.527219+00:00— report_created — created