I HATE PYTHON
I HATE PYTHON
Posted May 21, 2025 20:02 UTC (Wed) by NYKevin (subscriber, #129325)In reply to: I HATE PYTHON by dskoll
Parent article: Recent disruptive changes from Setuptools
It's not magic. It's one flag.
sudo pip install --break-system-packages [...]
The problem is, now your system package manager doesn't know that you went behind its back and installed random things into /usr with a third-party tool. At best, this causes some confusion about which files are managed by the system and which are "managed" by you manually running pip. At worst, it actually does cause some system packages to break, because they were tested against version X of libfoo and you installed version Y. Pip is entirely right to tell you not to do it - it can and will break your system in unpredictable ways, hence why it is called --**break**-system-packages and not e.g. --global-install or some innocuous-sounding thing.
Pip used to work in the exact manner you describe (silently overwriting system-wide packages if invoked with appropriate privileges). It was changed because too many users were accidentally breaking their systems (as discussed at the time in https://peps.python.org/pep-0668/#motivation). So now, it will only break your system if you ask it to do so, which IMHO is a win.
Also, I know that you do have an OS package manager to break, because you would not be getting that error message if you didn't. Pip looks for a file named EXTERNALLY-MANAGED in the package directory, and that file is not distributed with upstream Python, so it can only exist if your distro put it there to indicate that pip should not touch it. In other words: Your problem is between you and your distro, and pip is just the messenger.
Here are some alternatives that are less terrible:
* pip install --user [...], which installs into a subdirectory of $HOME.
* Make a venv. A venv is not heavy or difficult to work with, although Debian users need to install python3-venv. It's literally just a directory with a copy of (or symlink to) the Python binary, plus some scripting gunk to tell Python and pip to use that directory as the installation root (instead of some directory or combination of directories under /usr/lib).
* Use your OS package manager to install the desired OS packages instead. Pip doesn't support doing this automatically, presumably because it does not want to build out integrations with APT and RPM and Pacman and... etc., as well as converting the PyPI name of a package into the name used by the OS repository. Don't ask me how Perl figured that one out, I'm not a Perl person.
* Configure Python so that it has a separate package directory under /usr/local where you can do whatever you want, without breaking the OS package manager, and then pip will not complain about system-wide installations. See https://docs.python.org/3/library/site.html and https://packaging.python.org/en/latest/specifications/ext... for how this works internally.
