After running "pip install --upgrade pip" pip tells me the same thing

While install a package:

....................
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Ok:

$ pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 961kB/s 
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Why? How to fix it?


Solution 1:

To upgrade pip using pip is a bit different than regular command. Use

python -m pip install --upgrade pip

Here python -m will read the pip library file as a script and you will be able to update.

Solution 2:

Run the command to upgrade pip as root so pip can be upgraded if it is installed in the following location:

$ pip -V
pip 10.0.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)

Command to upgrade pip:

sudo python -m pip install --upgrade pip  

Command to upgrade pip3 (for Python 3.x):

sudo python3 -m pip install --upgrade pip

Explanation of the --upgrade option of pip install:

-U, --upgrade
             Upgrade all packages to the newest available version. This
             process is recursive regardless of whether a dependency is
             already satisfied.

Solution 3:

I don't know how it is done for pip-8 on Ubuntu-16, but I guess you could do it the same way I updated my pip-9 on Ubuntu-18 to current pip-20:

On Linux or macOS:

pip install -U pip

globally or for specific versions/installations:

python -m pip install -U pip
python3 -m pip install -U pip
python3.8 -m pip install -U pip
etc.

On Windows:

python -m pip install -U pip

Source

Cause line "python -m pip install --upgrade pip" from Installing packages using pip and virtual environments didn't work for me.

Solution 4:

If you were like me you had created a virtual environment in a project folder. python -m venv env

So in order to make the pip upgrade work, go into the Scripts folder of the env folder.

Then run .\python -m pip install --upgrade pip.

Ditto with any pip installs. Same folder .\pip install ....

The .\ pins it to the command in the current folder, be it pip or python.

(I was doing this on Windows. But ./ would be the equivalent for Unix variants)

PS: I also ran those commands as Administrator - so sudo the commands if things fails.

Solution 5:

__main__.py was moved to _internal in the later versions of python. This file should not exist in dist-packages or .local.

Try one of these based on what python version you are using. Then try pip2 -V. Worst case, you can put them back.

sudo mv /usr/local/lib/python3.5/dist-packages __main__.py /tmp
pip3 -V
sudo mv /usr/local/lib/python2.7/dist-packages __main__.py /tmp
pip2 -V
sudo mv ~.local/lib/python2.7/site-packages __main__.py /tmp