Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

Older pip rejects the --break-system-packages flag

Your error

no such option: --break-system-packages1 more line it can show

Fix it fast

Most common cause, 1 of 2

The script targets new distributions but runs on an older system Python

On those hosts the flag can simply go.

Fix
# works with pip 22 and pip 26 alike
PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip install requests

# Dockerfile form
ENV PIP_BREAK_SYSTEM_PACKAGES=1
RUN python3 -m pip install -r requirements.txt
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

pip prints no such option: --break-system-packages when it is older than 23.0.1, the release that added the flag, for example the pip 22.0.2 that Ubuntu 22.04 installs from apt. Such pip never reads the EXTERNALLY-MANAGED marker, so the flag is not needed there. Drop it, or set PIP_BREAK_SYSTEM_PACKAGES=1, which older pip silently ignores.

  • Applies to pip 23.0.1 to 26.3 (flag available), pip 22.0.2 and older (flag unknown), Ubuntu 22.04, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Ask the same interpreter your script uses for its pip version and location. Below 23.0.1 the flag does not exist; the path shows whether that pip belongs to the system Python (cause 1) or to a virtual environment (cause 2).

Run this first
python3 -m pip --version

Then find the line you see in this list and open its fix:

  1. 1The script targets new distributions but runs on an older system Pythonpip reports 22.x or older from a system path such as /usr/lib/python3/dist-packages, as on Ubuntu 22.04 or images built on it
  2. 2The command runs inside a virtual environment that has an old pipThe pip path printed by the first step sits inside a venv or virtualenv folder, and its version is below 23.0.1

What does the error look like?

  • no such option: --break-system-packages
  • pip install [options] <requirement specifier> [package-index-options] ...

Cause 1 of 2

The script targets new distributions but runs on an older system Python

You seepip reports 22.x or older from a system path such as /usr/lib/python3/dist-packages, as on Ubuntu 22.04 or images built on it

Check

no such option: --break-system-packages from a system pip means that pip predates the option. pip 23.0 began honouring the EXTERNALLY-MANAGED file and 23.0.1 added the override, so an older pip never blocks installs and has nothing to override. Ubuntu 22.04 ships python3-pip 22.0.2.

Check
python3 -m pip install --help | grep -c -- --break-system-packages

Fix

On those hosts the flag can simply go. When one script or Dockerfile must serve old and new releases, move the setting into the environment: pip skips configuration values it has no option for, so older versions ignore it while 23.0.1 and later apply it.

Fix
# works with pip 22 and pip 26 alike
PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip install requests

# Dockerfile form
ENV PIP_BREAK_SYSTEM_PACKAGES=1
RUN python3 -m pip install -r requirements.txt

Verify

The install finishes on the old host, and on Ubuntu 24.04 it no longer stops with externally-managed-environment.

Verify
python3 -m pip show requests | grep Version

Confirmed by pip.pypa.io

Did this fix it?

Cause 2 of 2

The command runs inside a virtual environment that has an old pip

You seeThe pip path printed by the first step sits inside a venv or virtualenv folder, and its version is below 23.0.1

Check

PEP 668 says packages inside a virtual environment belong to that environment, and installers only apply the marker outside one. Passing the override in a venv therefore does nothing useful, and an older seeded pip refuses the unknown word.

Check
python -c "import sys; print(sys.prefix != sys.base_prefix)"

Fix

Remove the flag from commands that run in the venv. If shared tooling must keep it, upgrade the venv's own pip first so the option is recognised.

Fix
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install -r requirements.txt

Verify

The venv's pip reports 23.0.1 or newer, or the command succeeds once the flag is gone.

Verify
.venv/bin/python -m pip --version

Confirmed by peps.python.org

Did this fix it?

How do I stop it coming back?

  • Prefer PIP_BREAK_SYSTEM_PACKAGES in CI images over the command-line flag, because unknown environment settings do not break older pip.
  • Upgrade pip as the first step after creating any virtual environment, before installs that pass newer options.
  • Test install scripts on the oldest distribution release you still support, not only on the newest.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.