Python pip broken!

Well, no… If a command does not work with sudo that doesn’t mean you should just run it with sudo.

There are certain commands you should never, ever, run with sudo (I call them: sudon't).

For example, a GUI text editor won’t let you edit a root owned file unless you run it with sudo, but you know that you should never do that – never run GUI programs with sudo.

In the case of pip, on Arch Linux (and EndeavourOS) you certainly shouldn’t run it with sudo, ever. Without sudo pip won’t let you globally install Python modules, and that’s the whole point – you shouldn’t be doing that. Instead, you should be using pacman (ALPM) to install all global packages, including Python modules. This way, they won’t be invisible to the ALPM.

The same thing is true for npm (for JavaScript) and gem (for Ruby), as well as any other third party package (module) manager. It is safe to use them to install modules locally, but they shouldn’t be used with sudo to install modules globally. On some distros, like Debian and 'Buntu that’s fine, but on Arch, that can cause serious system misbehaviour that can be very difficult to troubleshoot.

TL;DR: don’t use sudo when you shouldn’t be using sudo, even if the command does not work without sudo. Specifically, don’t use sudo with GUI programs and third party package managers like pip, npm, and gem.

4 Likes