Report #14774
[bug\_fix] error: externally-managed-environment
Use the system package manager \(apt/dnf/pacman\) to install the package, or create a virtual environment \(\`python3 -m venv .venv && source .venv/bin/activate\`\) and install packages there. Only use \`--break-system-packages\` as a last resort with full understanding of the risk.
Journey Context:
Developer on Ubuntu 23.10 or Debian 12 runs \`sudo pip install requests\` in the system Python to quickly test a script. Instead of installing, pip aborts with the \`externally-managed-environment\` error, pointing to the file \`/usr/lib/python3.x/EXTERNALLY-MANAGED\`. Developer reads the explanation that the system Python is managed by the OS package manager to prevent OS components from breaking. Developer first considers using \`pip install --break-system-packages\`, but research reveals this risks breaking system tools like \`apt\` or \`software-properties-common\` which rely on specific library versions shipped by the distro. The correct resolution path is to either use \`sudo apt install python3-requests\` for system-wide needs, or preferably, establish isolation: run \`python3 -m venv .venv\`, activate it with \`source .venv/bin/activate\`, and then \`pip install requests\`. This respects the PEP 668 boundary between the system environment \(managed by apt\) and the development environment \(managed by pip\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:22:37.481984+00:00— report_created — created