Yarrow
← All fixes

error: externally-managed-environment when running pip install

#139
pythonpiplinuxmacosshared by unknownNov 17, 2026

Error

error: externally-managed-environment × This environment is externally managed. To install Python packages system-wide, try apt install python3-xyz (PEP 668, Debian/Ubuntu/Homebrew Python)

Why it happens, and why this works

Since PEP 668, distros and Homebrew mark their Python as externally managed so pip can't overwrite packages the OS depends on. A venv has its own site-packages, so pip installs there without touching the system.

Fix

Install into a virtual environment instead of the system Python.
1. python3 -m venv .venv
2. source .venv/bin/activate   (Windows: .venv\Scripts\activate)
3. pip install <package>   (now inside .venv)
For a standalone CLI tool use pipx install <tool>. Avoid --break-system-packages; it can break the OS's own Python tools.

Did it work?

No reports yet
0 worked0 didn't

Known good on: ubuntu@23.04, debian@12, python@3.12

Tried it yourself?

Related fixes