Fix: pip error: no such option: --break-system-packages
Part of: Python Errors
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.” The mechanism is simple: the distro ships an empty file at /usr/lib/python3.X/EXTERNALLY-MANAGED and a small pip patch that checks for it. When the file is present, pip refuses to install or remove anything in the system site-packages and prints the externally-managed-environment message instead. This prevents pip from overwriting files owned by apt or dnf, which historically caused broken system tools (a botched pip install requests --upgrade could leave apt unusable on Ubuntu).
When you try pip install <package>, you get externally-managed-environment. The fix suggested in the error text is --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 and you get no such option: --break-system-packages. The cruel twist is that PEP 668 enforcement and --break-system-packages support shipped on slightly different timelines per distro, so you can end up on a system that enforces the policy but ships a pip that does not know how to bypass it.
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.
- Vendored pip in a CI runner. GitHub Actions and similar runners cache a specific pip version that lags the latest release; the runner image you happened to schedule on may not have the flag.
Platform and Environment Differences
PEP 668 has rolled out at very different times per distribution and per Python installation method, which is exactly why the error feels random across machines.
Debian and Ubuntu. Debian 12 “bookworm” (June 2023) was the first major distro to ship the EXTERNALLY-MANAGED marker by default for the system Python. Ubuntu 23.04 followed in April 2023, and 24.04 LTS made it the long-term default. Debian 11 / Ubuntu 22.04 do not enforce PEP 668, so the same pip install command works on a 22.04 server and fails on a 24.04 desktop — confusing if you keep multiple machines. The python3-pip package on bookworm is recent enough to support --break-system-packages; the version on older Ubuntu LTS may not be.
Fedora and RHEL family. Fedora 38 (May 2023) enabled PEP 668 for /usr/bin/python3. Fedora 39 and 40 keep it on. RHEL 9 and AlmaLinux/Rocky 9 do not enforce it on the system Python yet, but the AppStream Python modules (python3.11, python3.12) do for installations under /usr/lib/python3.X. CentOS Stream tracks Fedora behavior, so expect PEP 668 on recent streams.
Arch Linux. Arch enabled PEP 668 in March 2024 with the python package update to 3.11+. Because Arch is rolling-release, the change hit every up-to-date Arch box in the same week, generating a flood of identical questions. The Arch wiki recommends pipx for global tools.
Homebrew on macOS. Homebrew’s [email protected] and [email protected] formulae mark the installation as externally managed (the marker file lives inside the Homebrew Cellar). Apple Silicon (/opt/homebrew/...) and Intel (/usr/local/...) behave identically. The system /usr/bin/python3 shipped by Apple is also externally managed, with a different message that points you at the App Store version. Neither installation is intended to receive pip install directly — Homebrew specifically recommends a venv or pipx.
Windows native. The Python.org installer for Windows does not ship the EXTERNALLY-MANAGED marker. You will not see this error on a stock Windows Python install. The only way to hit it on Windows is to install Python through WSL2 (which then behaves like the underlying Ubuntu/Debian distro), or through the Microsoft Store version of Python which mirrors some of the same behavior in restricted profiles.
WSL2. Inherits the host distro’s behavior exactly. A WSL2 Ubuntu 24.04 enforces PEP 668; a WSL2 Ubuntu 20.04 does not. Note that pip installs under WSL2 still write into the WSL2 filesystem, not into the Windows Python — they are entirely separate installations.
Docker base images. The official python:3.X and python:3.X-slim images on Docker Hub do not enable PEP 668. They are built specifically so RUN pip install -r requirements.txt Just Works without ceremony. The trap is FROM ubuntu:24.04 or FROM debian:12 + apt install python3 python3-pip — those images do enforce PEP 668 because they inherit the distro defaults. If you switched a Dockerfile from FROM python:3.12-slim to FROM ubuntu:24.04 to bundle other tools, your pip install line breaks even though Python is “the same version.”
Older pip (no --break-system-packages flag). The flag was added in pip 23.0.1 (February 2023). Any pip older than that — including the python3-pip package in older repos and pip versions vendored into long-lived Docker images — does not recognize the option. pip --version is the first thing to check when you see the no such option error.
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.
The /opt/venv + ENV PATH pattern is worth committing to memory. It moves the venv outside the project tree (so a bind mount during local development does not erase it), makes every subsequent RUN pip install and CMD python ... automatically use the venv without needing source activate, and produces a slimmer final image because the venv directory is easy to COPY --from=builder in a multi-stage build.
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.
The damage from a bad system-wide install is real. On Debian/Ubuntu, apt itself uses /usr/lib/python3/dist-packages/apt_pkg.cpython-*.so. If a pip-installed package overwrites a shared dependency with an incompatible version, apt update starts throwing ImportError and you can no longer install or remove anything via apt. Recovery usually requires booting from rescue media or running dpkg --force-reinstall on every Python-dependent package. The --break-system-packages flag is named that way for a reason.
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 purgeConfirm the marker file location. PEP 668 enforcement is triggered by an EXTERNALLY-MANAGED file next to the Python standard library. Find yours:
find /usr/lib/python3* /usr/local/lib/python3* /opt -name "EXTERNALLY-MANAGED" 2>/dev/nullIf the file exists, you are on a managed Python. If not, the error is coming from a different mechanism (a pip.conf override, a wrapper script, or a conda env that has its own policy). Knowing which file triggered the message tells you exactly which Python you are talking to.
Verify the pip you are running matches the python you are running. A surprisingly common cause of “I upgraded pip but the flag still does not work” is that pip on $PATH belongs to a different interpreter than python3. Always invoke via the interpreter to remove ambiguity:
python3 -m pip --version
python3 -m pip install --upgrade pipCheck container base image age. A Dockerfile that pinned FROM python:3.10-slim two years ago has a pip from that era. Either update the base image or add RUN pip install --upgrade pip as the first step after FROM.
For 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.