On this page
You ran an ordinary install:
python3 -m pip install requestsand pip refused:
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the package you are trying to
install.This is not a bug and not a broken install. It is a deliberate guard, and once you know what it protects, the fix is quick.
What the error means#
Your operating system or package manager (Homebrew, in this case) ships its own Python and uses it for its own tools. If you run pip install against that interpreter, pip can upgrade or overwrite libraries that those tools rely on, and you can break them in ways that are painful to untangle.
PEP 668 gave distributions a standard way to say "do not let pip modify this Python". They place a small marker file called EXTERNALLY-MANAGED in the interpreter's standard library folder, and pip checks for it. On Homebrew's Python 3.13 the file is here:
/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib/python3.13/EXTERNALLY-MANAGEDWe confirmed the same behaviour on Homebrew's 3.12. The python.org installer's Python 3.14 has no marker, so the same command raised no such error. That is why the error seems to appear "randomly" depending on which Python you reach first.
Fix 1: use a virtual environment (the right answer for projects)#
A virtual environment is a private copy of Python and its packages, just for one project. pip does not apply the restriction inside one, so installs simply work:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install requestsWe checked where the package landed:
requests 2.34.2 installed in /private/tmp/em/.venvIt went into the environment's own folder, not the system. We also confirmed that running pip from inside the environment raised no externally-managed error at all. Activate the environment each time you open a new terminal, or call .venv/bin/python directly.
Fix 2: install the package with your system package manager#
On Homebrew, many Python libraries are available as ordinary packages:
brew install <package>The error message itself suggests this for system-wide tools. This is not run here, because it depends on whether your package exists in Homebrew. It is a good fit when you want a command-line tool available everywhere, and a poor fit when your project needs a specific library version.
Fix 3: use pipx for command-line applications#
If what you want is a program written in Python, such as a formatter or a linter, rather than a library to import, the error message points to pipx, which gives each application its own isolated environment:
pipx install <application>This is not run here, since pipx was not installed on the test machine, so we are quoting what the error message recommends rather than showing output.
Fix 4: override it, knowing the risk#
If you understand the risk and truly want to install into the system interpreter, pip has an explicit override:
python3 -m pip install --break-system-packages requestsWe verified it with a dry run, which resolves the install without changing anything:
Would install certifi-2026.7.22 charset-normalizer-3.5.2 idna-3.20 requests-2.34.2 urllib3-2.8.0The flag name is blunt on purpose. Homebrew's message warns that without also passing --user, you can end up with a broken Homebrew installation.
What does not work#
Two common guesses do nothing. Adding --user on its own does not bypass the protection. We ran it:
python3.13 -m pip install --dry-run --user requestserror: externally-managed-environmentAnd deleting the EXTERNALLY-MANAGED file will make the error vanish, but it removes the safety net for everything on that Python, and a Homebrew upgrade may put it back. Use a virtual environment instead.
Which fix should you pick?#
| You want... | Use |
|---|---|
| Libraries for one project | Virtual environment |
| A command-line tool, available everywhere | pipx or brew install |
| A quick throwaway install, and you accept the risk | --break-system-packages |
| To stop hitting this on every project | Make python -m venv a habit |
Related#
If you are not sure which interpreter you are even running, see ModuleNotFoundError: No module named, which shows how to check. And if an install fails with a build error rather than this one, read the setup.py bdist_wheel error.