Report #97164
[bug\_fix] PEP 668 'externally managed environment' error when running pip install on system Python
Create and activate a virtual environment, then install inside it: \`python -m venv .venv && source .venv/bin/activate && python -m pip install \`. Only as a last resort on a personal machine \(never on a managed system\) may you use \`--break-system-packages\` with \`pip install\`. On Debian/Ubuntu, prefer \`apt install python3-\` for system-wide packages.
Journey Context:
On Ubuntu 22.04 or later you run \`sudo pip install requests\` and pip aborts with \`error: externally-managed-environment\` and a message telling you to use a virtual environment. The distribution has placed a marker file \(\`/usr/lib/python3.x/EXTERNALLY-MANAGED\`\) to prevent pip from overwriting files that belong to the OS package manager, which can break \`apt\` and system tools. After switching to \`python -m venv .venv\` and activating it, pip no longer sees the marker, installs into the isolated environment, and the system Python remains untouched.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:39:31.166981+00:00— report_created — created