Ubuntu – How to perform a full reinstallation of pip and pip3

package-managementpippython

I want out of my computer what everyone else wants: for it to work properly.

Now on to the problem: I was trying to install a package via pip3 when I got a message indicating that I was using an outdated version of pip3. I tried installing the new version using pip install --upgrade pip. Long story short, my computer's managed to get itself stuck using pipV8, which is more than 10 versions behind where it needs to be. This is a problem with both pip and pip3.

Now, usually I'd be able to fix this on my own, but it seems to me that there's still some hidden statefulness from either my system's packages, existing files, or pip's own cache that prevents me from performing a complete removal and re-installation (because I'm not going to try to perform an upgrade at this point).

What must I do in order to remove pip and pip3 completely from my system, and subsequently install their fully up-to-date versions?

Best Answer

To completely remove and reinstall pip and pip3 in all currently supported versions of Ubuntu open the terminal and type:

sudo apt purge python-pip python3-pip  
sudo apt install python-pip python3-pip  
pip uninstall --user pip  
pip3 uninstall --user pip3  

Removing a package removes all packaged data, but leaves usually small (modified) user configuration files behind, in case the remove was an accident. Just issuing an installation request for the accidentally removed package will restore its function as before in that case. On the other hand you can get rid of these leftovers by calling purge even on already removed packages. Note that this does not affect any data or configuration stored in your home directory.

Related Question