Affected versions: Ubuntu 24.04 LTS

📖 ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

Global pip install fails due to PEP 668 externally managed environment policy.

Environment & Reproduction

Occurs on Ubuntu 24.04 when using system Python for package installs.

python3 -m pip install requests

Root Cause Analysis

System Python is protected to avoid conflicts with apt-managed packages.

Quick Triage

Confirm whether command is running in system interpreter or virtual environment.

which python3
python3 -m pip --version

Step-by-Step Diagnosis

Inspect marker files and pip behavior for active interpreter.

python3 -c 'import sys; print(sys.prefix)'
ls /usr/lib/python3*/EXTERNALLY-MANAGED
Illustrative mockup for ubuntu-24-04-lts — terminal_or_shell
Diagnostic output for python/pip-externally-managed — Illustrative mockup — Progressive Robot

Solution – Primary Fix

Use virtual environment for project dependencies and install with pip inside it.

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
python -m pip install requests
Illustrative mockup for ubuntu-24-04-lts — log_or_console
Resolution output for python/pip-externally-managed — Illustrative mockup — Progressive Robot

Solution – Alternative Approaches

Use pipx for standalone CLI apps managed outside system site-packages.

sudo apt install pipx -y
pipx install httpie

Verification & Acceptance Criteria

Packages install successfully in isolated environment without system conflicts.

source .venv/bin/activate
python -m pip list

Rollback Plan

Remove virtual environment and recreate if dependency graph becomes inconsistent.

deactivate 2>/dev/null || true
rm -rf .venv

Prevention & Hardening

Standardize project templates to always include per-project virtual environments.

python3 -m venv .venv

Related message is externally-managed-environment with suggestion to use venv.

Related tutorial: View the step-by-step tutorial for Ubuntu 24.04 LTS.

View all Ubuntu 24.04 LTS tutorials on the Tutorials Hub →

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

PEP 668 and Ubuntu Python packaging policy references.

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.