Fix: pip error: no such option: --break-system-packages
Quick Answer
How to fix pip error no such option --break-system-packages caused by old pip versions, PEP 668 externally-managed environments, and virtual environment setup on modern Linux distributions.
The Error
You try to install a Python package and get:
error: externally-managed-environmentYou follow advice to add --break-system-packages and get:
Usage: pip install [options] <requirement specifier> ...
no such option: --break-system-packagesOr:
ERROR: no such option: --break-system-packagesYour pip version is too old to support the --break-system-packages flag. This flag was added in pip 23.0.1 to work with PEP 668 (externally-managed Python environments), which is enforced by newer Linux distributions like Ubuntu 23.04+, Debian 12+, and Fedora 38+.
Why This Happens
Starting with PEP 668, modern Linux distributions mark their system Python as “externally managed.” This prevents pip from modifying system-wide packages, which could break the OS.
When you try pip install <package>, you get externally-managed-environment. The fix is supposed to be --break-system-packages — but this flag only exists in pip 23.0.1 and later. If your pip is older, the flag is not recognized.
Common scenarios:
- Old pip in the system Python. The system pip is an older version that predates PEP 668 support.
- Virtual environment not activated. You are using system pip instead of a virtual environment’s pip.
- Pip installed via apt/dnf. The system package manager installed an old pip version.
- Docker base image with old pip. The base image has an outdated pip.
Fix 1: Use a Virtual Environment (Recommended)
The correct fix. Virtual environments bypass the externally-managed restriction entirely:
python3 -m venv myenv
source myenv/bin/activate
pip install <package>Inside a virtual environment, pip installs packages into the venv’s isolated directory, not the system Python. No flags needed.
Create a venv in your project directory:
cd /path/to/project
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtDeactivate when done:
deactivatePro Tip: Always use virtual environments for Python projects. They prevent conflicts between project dependencies and keep the system Python clean. This is not just a workaround — it is the intended workflow for Python development on modern systems.
If python3 -m venv itself fails, install the venv module:
# Ubuntu/Debian
sudo apt install python3-venv
# Fedora
sudo dnf install python3-virtualenvFor more on the externally-managed-environment error itself, see Fix: pip externally-managed-environment.
Fix 2: Upgrade pip
If you must use --break-system-packages (not recommended), upgrade pip first:
python3 -m pip install --upgrade pipIf this itself fails due to the externally-managed restriction:
# Download and run the pip installer directly
curl -sS https://bootstrap.pypa.io/get-pip.py | python3 --userOr upgrade via the system package manager:
# Ubuntu/Debian
sudo apt install python3-pip
# Fedora
sudo dnf install python3-pipAfter upgrading, verify the version:
pip --version
# pip 24.x.x from /usr/lib/python3/dist-packages/pip (python 3.12)If pip is version 23.0.1 or higher, --break-system-packages is available.
Fix 3: Use pipx for CLI Tools
If you are installing command-line tools (like black, flake8, httpie), use pipx:
# Install pipx
sudo apt install pipx
# or
python3 -m pip install --user pipx
# Install CLI tools
pipx install black
pipx install httpie
pipx install poetrypipx creates an isolated virtual environment for each tool automatically. The tools are available globally without touching the system Python.
List installed tools:
pipx listUpgrade a tool:
pipx upgrade blackFix 4: Use the —user Flag
Install packages in the user directory instead of system-wide:
pip install --user <package>This installs to ~/.local/lib/python3.x/site-packages/, which does not require root and does not conflict with system packages.
Note: On newer systems with PEP 668, even --user might be blocked. The virtual environment approach (Fix 1) is the most reliable solution.
If the --user install works but the package is not found when you run it, add ~/.local/bin to your PATH:
export PATH="$HOME/.local/bin:$PATH"Add this to your ~/.bashrc or ~/.zshrc to make it permanent. If Python itself is not found, see Fix: python command not found.
Fix 5: Fix Docker Containers
Docker images based on newer distributions also enforce PEP 668:
Broken:
FROM python:3.12-slim
RUN pip install flask # May fail with externally-managed-environmentActually, the official python Docker images do not mark Python as externally managed. But images based on ubuntu:24.04 or debian:12 do.
Fix for Ubuntu/Debian-based images:
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y python3 python3-venv python3-pip
# Option 1: Use a virtual environment (recommended)
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install flask
# Option 2: Remove the externally-managed marker (hacky)
# RUN rm /usr/lib/python3.*/EXTERNALLY-MANAGED
# RUN pip install flaskCommon Mistake: Removing the
EXTERNALLY-MANAGEDfile in Docker containers. While it works, it defeats the purpose of the safety mechanism. Use a virtual environment even in Docker — it is cleaner and matches production best practices.
Fix 6: Use conda or mamba
If you use Anaconda or Miniconda, use conda instead of pip:
conda install flask
conda install -c conda-forge blackOr use mamba for faster dependency resolution:
mamba install flaskConda manages its own Python environments and does not interact with the system Python or PEP 668 restrictions.
Fix 7: Configure pip Globally (Not Recommended)
As a last resort, you can globally allow --break-system-packages in pip’s config:
mkdir -p ~/.config/pip
cat > ~/.config/pip/pip.conf << 'EOF'
[global]
break-system-packages = true
EOFWarning: This disables the PEP 668 protection permanently. If you install a package that conflicts with a system package, you could break your OS’s Python-dependent tools (like apt on Ubuntu). Only do this on development machines you can easily rebuild.
Still Not Working?
If you have tried all the fixes above:
Check which pip you are using:
which pip
which pip3
pip --version
pip3 --versionYou might have multiple Python and pip installations. Make sure you are using the correct one.
Check for pyenv. If you use pyenv, the pyenv-managed Python is not externally managed and pip works normally:
pyenv install 3.12
pyenv local 3.12
pip install flask # Works without restrictionsCheck for snap-installed Python. On Ubuntu, snap install python3 installs a sandboxed Python. Use the system Python or pyenv instead.
Check pip cache issues. A corrupted pip cache can cause unexpected errors:
pip cache purgeFor SSL certificate issues when pip tries to download packages, see Fix: pip SSL certificate verify failed.
If pip itself is missing entirely and you get ModuleNotFoundError: No module named 'pip', reinstall pip:
python3 -m ensurepip --upgradeFor general issues with pip failing to build packages, see Fix: pip could not build wheels.
Solo developer based in Japan. Every solution is cross-referenced with official documentation and tested before publishing.
Was this article helpful?
Related Articles
Fix: ERROR: Could not build wheels / Failed building wheel (pip)
How to fix pip 'ERROR: Could not build wheels', 'Failed building wheel', 'No matching distribution found', and 'error: subprocess-exited-with-error'. Covers missing C compilers, build tools, system libraries, Python version issues, pre-built wheels, and platform-specific fixes for Linux, macOS, and Windows.
Fix: error: externally-managed-environment (pip install)
How to fix the 'error: externally-managed-environment' and 'This environment is externally managed' error when running pip install on Python 3.11+ on Ubuntu, Debian, Fedora, and macOS.
Fix: pip SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed
How to fix the pip SSL CERTIFICATE_VERIFY_FAILED error when installing Python packages, covering corporate proxies, trusted-host flags, certifi, pip.conf, macOS, Windows, and Docker environments.
Fix: Python PermissionError: [Errno 13] Permission denied
How to fix Python PermissionError Errno 13 Permission denied when reading, writing, or executing files, covering file permissions, ownership, virtual environments, Windows locks, and SELinux.