📖 ~1 min read
Table of contents
Symptom & Impact
pip refuses system-wide installs with externally-managed-environment error.
Environment & Reproduction
Expected behavior on modern Ubuntu where Python system packages are protected.
python3 --version
pip3 --version
pip3 install requests
Root Cause Analysis
PEP 668 protection prevents pip from altering distro-managed Python environment.
Quick Triage
Determine whether requirement belongs in venv, pipx, or apt package.
apt search python3-requests
python3 -m site
pip3 config list
Step-by-Step Diagnosis
Check project layout and interpreter path to avoid mixed package managers.
which python3
which pip3
python3 -c 'import sys; print(sys.prefix)'
python3 -m venv --help

Solution – Primary Fix
Use a virtual environment for project dependencies and install there.
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install requests

Solution – Alternative Approaches
Use pipx for CLI tools or apt for system-provided Python modules.
sudo apt install pipx -y
pipx install black
sudo apt install python3-requests -y
Verification & Acceptance Criteria
Accepted when package installs succeed in intended environment and app imports pass.
source .venv/bin/activate
python -c 'import requests; print(requests.__version__)'
Rollback Plan
Remove virtual environment if migration must be reverted quickly.
deactivate || true
rm -rf .venv
Prevention & Hardening
Standardize Python workflows to venv or pipx and avoid global pip writes.
python3 -m venv --upgrade-deps .venv
pipx list
Related Errors & Cross-Refs
Related errors include externally-managed-environment and permission denied writing dist-packages.
Related tutorial: View the step-by-step tutorial for Ubuntu 26.04 LTS.
View all Ubuntu 26.04 LTS tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
PEP 668, Ubuntu Python policy docs, pipx docs, and Python venv documentation.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.