Python & dev · pip / Debian / Ubuntu / Homebrew macOS
pip blocked by PEP 668 externally-managed-environment
Error message
error: externally-managed-environmentWhy it happens
Modern Linux distros and Homebrew Python mark the system Python as externally managed (PEP 668) to prevent pip from breaking OS-managed packages.
How to fix it
- Create and activate a project virtual environment: python3 -m venv .venv && source .venv/bin/activate, then run pip install.
- For standalone CLI tools, install via pipx install <package> or uv tool install <package>.
- On Debian/Ubuntu, install system-wide Python libraries via apt instead: sudo apt install python3-<package>.
- Only inside disposable containers/CI, override the guard with pip install –break-system-packages <package>.
python3 -m venv .venv && source .venv/bin/activateSeeing a different message? Paste it into the Error Code Fixer
Related errors
- PyTorch CUDA Out of Memory
- PyTorch Cannot Detect CUDA GPU
- PyTorch Installed Without CUDA
- Connection refused on port 11434
Fixes are reviewed by ComputerTech against current documentation, and software changes fast. If a step differs on your version, tell us. Back up important data before changing drivers, BIOS or system files.