Ubuntu – How to uninstall duplicate PIP in Python3 on Ubuntu 20.04


I have a clean installation with Ubuntu 20.04 and use Python3. I once installed PIP with sudo apt install python3-pip. I use "pip3" always as "pip" doesn't exist and it reminds me that only Python 3 is installed (by default).

I entered pip3 install --upgrade pip wanting to check/upgrade pip3:

myname@name-X570-AORUS-ULTRA:~/Desktop$ pip3 install --upgrade pip
Collecting pip
  Downloading pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 2.8 MB/s 
Installing collected packages: pip
Successfully installed pip-20.2.4

Unintentionally I now have two different versions of pip installed (without Python 2.7):

myname@name-X570-AORUS-ULTRA:~/Desktop$ pip --version
pip 20.2.4 from /home/aendie/.local/lib/python3.8/site-packages/pip (python 3.8)
myname@name-X570-AORUS-ULTRA:~/Desktop$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

pip3 list includes pip 20.0.2 and
pip list includes pip 20.2.4. Also the locations are …

myname@name-X570-AORUS-ULTRA:~/Desktop$ whereis pip
pip: /home/myname/.local/bin/pip /home/myname/.local/bin/pip3.8
myname@name-X570-AORUS-ULTRA:~/Desktop$ whereis pip3
pip3: /usr/bin/pip3 /home/myname/.local/bin/pip3 /home/myname/.local/bin/pip3.8 /usr/share/man/man1/pip3.1.gz

QUESTION 1: did I upgrade PIP correctly? If not, what is the correct command?

QUESTION 2: how can I remove the older pip version (for consistency)?

QUESTION 3: what is "best practice" when upgrading PIP in Python 3. (My documentation quotes use of "pip3" as initially "pip" didn't exist and it would be confusing to advise use of "pip" if "pip3" is older!)


My question does not concern my computer – it concerns my documentation for other users that may have a different OS and Python 2 or Python 3 or both installed. I have both on Windows 10 and only Python 3 on Ubuntu 20.04. In my Windows 10 both pip and pip3 return the same version number:

C:\Users\Andrew>pip --version
pip 20.2.4 from c:\python39\lib\site-packages\pip (python 3.9)
C:\Users\Andrew>pip3 --version
pip 20.2.4 from c:\python39\lib\site-packages\pip (python 3.9)

Aha! I thought pip worked only with Python 2 and pip3 with Python 3. I was wrong here 🙁

Especially seeing that "pip for Python 3" and "pip for Python 2" are quoted here:
as well as "Replace pip3 with pip if using Python 2".

Thus I was confused when in Ubuntu 20.04 I got pip in addition to pip3 – I thought pip is the version for Python 2, which is not installed on my Ubuntu! So after installing pip3 with sudo apt install python3-pip I simply wanted to know how to check/upgrade it (when eventually a new version comes along).

With pip3 install --upgrade pip I was expecting pip3 to change from 20.0.2 to 20.2.4. It didn't – instead it installed pip in parallel with pip3. So what is the command to upgrade pip3 without installing a separate pip?

P.S. I don't want to install with get-pip.py – I want the simple solution.

Best Answer

when you upgraded pip3 it installed the new pip version in /home/YOU/.local/lib/python3.8/site-packages and it didnt remove the old pip version because it is stored in /usr/lib/python3/dist-packages/pip, the directory /usr/lib/python3/dist-packages/pip you installed the old pip version with apt so it is only apt that can remove the old pip.

in QUESTION 2 the

pip3 --version 

is from /usr/lib/python3/dist-packages/pip which means it was installed by apt, to remove the older pip package you can run (recommended)

sudo apt remove python3-pip

You can still run pip3 because it is another directory named /home/YOU/.local/bin/pip3 that it will replace the /usr/bin/pip3

if you want to remove the new pip version run

pip uninstall pip

in QUESTION 3 I recommend to upgrade pip with this command

python3 -m pip install --user --upgrade pip


The last command I recommended was only useful if you upgrade the pip in /home/YOU/.local/lib/python3.8/site-packages

sorry with the bad english, I am just 12 years old.

Related Question