I tried upgrading pip3 using su -c 'pip3 install' --upgrade pip' because I got errors and it failed when trying to upgrade it as a normal user.

This removed the pre-installed pip from /usr/bin and dumped it in /tmp, replacing it with a system wide installation of pip which is only accessible by root. I haven't tried to uninstall this new pip because I suspect it would lead to more problems.

Since I still have the old pre-installed pip in /tmp, how do I get back the pre-installed pip using this executable that is still in /tmp?

Location of pip in /tmp:

└── usr
    └── bin
        └── pip

It's likely that this was the package manager's version of pip, I'd simply re-install using your package manager.

$ sudo yum reinstall python-pip
$ sudo apt-get --reinstall install -y python-pip
  • At least in Debian python installed pip and the pip from the distro usually live in different places. – Rui F Ribeiro Jul 14 '18 at 15:10
  • @RuiFRibeiro - right, the OP said /usr/bin so that would fall in the realm of package managers. – slm Jul 14 '18 at 15:11
  • 1
    @MyWrathAcademia - yeah there's no need, the /usr/bin directory is owned by the package managers, so you really shouldn't be doing anything around them. Let the distros' tools for package management do their jobs. – slm Jul 14 '18 at 15:19
  • 1
    Also, make sure the SELinux labels are correct. (sudo restorecon /usr/bin/pip) – mattdm Jul 14 '18 at 15:48
  • 1
    That's probably a whole question on its own. SELinux is a mandatory access control system in the Linux kernel, and it uses filesystem labels (which you can see with ls -Z) to determine some of what is permitted. If you just copy a file around without properly preserving the labels, you will get a mismatch with the security policy and may not be able to run things. restorecon puts them back to how they're expected. – mattdm Jul 14 '18 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.