Modern Python (3.11+) and some Linux distributions prevent pip from installing packages globally to avoid conflicts with system package managers. You must use a virtual environment or install with appropriate flags.
Fixes How to fix 'externally-managed-environment' error in Python (PEP 668)
# How to fix 'externally-managed-environment' error in Python (PEP 668)
PEP 668 (introduced in Python 3.11 and adopted by Debian/Ubuntu) restricts pip from installing packages to the system Python. This prevents conflicts between pip packages and OS package managers (apt, yum, etc.). The error indicates you are trying to install globally instead of in a virtual environment or with --break-system-packages flag.
Review the error message above and identify which cause applies to your situation. Run additional diagnostics if needed.
Follow the corresponding solution from the causes section above.
Once you've addressed the root cause, try running 'pip install' again.