Python “externally-managed-environment”: use a virtual environment
Create a virtual environment and install there; that is the intended fix, not --break-system-packages.
This is pip protecting your system Python. Create a virtual environment (python3 -m venv .venv, activate it) and install there. Only use --break-system-packages in throwaway containers, never on your main system.
Try these fixes in order
Create a virtual environment
Create an isolated environment in your project directory. The venv's pip is not subject to the external-management guard.
python3 -m venv .venvActivate it
Activate the venv so python and pip resolve to the isolated environment in this shell.
source .venv/bin/activateInstall inside the venv
Install inside the venv. pip now writes to the venv's site-packages and the error is gone.
python -m pip install requestsOr use pipx for CLI tools
For standalone CLI tools you want on PATH, pipx creates a managed venv per tool instead of touching system Python.
pipx install blackInterpret what you see
You are on Debian/Ubuntu/Fedora system Python
What it suggests: PEP 668 marks the system interpreter as managed by the OS package manager. pip exits rather than risk breaking system software.
Next check: Create a venv with python3 -m venv and install inside it.
You want a command-line tool, not a library
What it suggests: pipx-style standalone tools and venvs are exempt; only the bare system interpreter is blocked.
Next check: If you need a CLI tool globally, use pipx install instead.
You are tempted to add --break-system-packages
What it suggests: --break-system-packages overrides the guard and can upgrade packages that OS tools depend on, breaking them.
Next check: Reserve the flag for containers you fully control, never for a desktop system Python.
Why this happens
- The distro's Python is marked externally managed (PEP 668), so pip refuses to write into its global site-packages.
- You ran pip install outside any virtual environment on Debian, Ubuntu, Fedora, or similar.
Still not working?
Do not delete the EXTERNALLY-MANAGED marker file to silence this; it protects system tools written in Python (like apt/dnf helpers) from being broken by pip upgrades. Use a virtual environment instead.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.