What does `error: externally-managed-environment` mean?
BeginnerConceptEnvironments, dependencies & packaging
Answer
PEP 668: Debian 12+, Ubuntu 23.04+, Fedora and Homebrew Python mark the system interpreter as managed by the OS package manager, and pip install into it is refused, to stop pip from breaking OS tools. Fixes, in order of preference:
python3 -m venv .venvand install there.pipx install <tool>for CLI applications.apt install python3-<pkg>for OS-level needs.
--break-system-packages exists, but using it on a server is how you break apt itself.
More on Environments, dependencies & packaging
What is a virtual environment and why do we always use one?Beginner`requirements.txt` vs `pyproject.toml`: what goes where?IntermediateWhy is `pip freeze > requirements.txt` not a great lock strategy?IntermediateWhat do version specifiers like `~=`, `==`, `>=,<` mean?BeginnerWhat are `pipx` and `uv`, and when do you use them?IntermediateHow do you manage multiple Python versions on one machine?Intermediate