The 'pip==7.1.0' distribution was not found and is required by the application

PythonPython 2.7UbuntuPip

Python Problem Overview


I have the latest version of pip 8.1.1 on my ubuntu 16. But I am not able to install any modules via pip as I get this error all the time.

File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 635, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 943, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 829, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==7.1.0' distribution was not found and is required by the application

I found a similar link, but not helpful.

Python Solutions


Solution 1 - Python

I repaired mine this with command:

> easy_install pip

Solution 2 - Python

I had this issue for a very long time until I recently found that my 'pip' file (/usr/local/bin/pip) is trying to load the wrong version of pip. I believe you also have 8.1.1 correctly installed on your machine and can give following a try.

  1. Open your /usr/local/bin/pip file. For me it looks like :

    __requires__ = 'pip==9.0.1'
    import sys
    from pkg_resources import load_entry_point
    if __name__ == '__main__':
        sys.exit(
            load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
    )
    
  2. Change 'pip==9.0.1' in line 1 and last line to whichever version you have installed on your system, for example you will need to change 7.1.0 to 8.1.1.

Basically /usr/local/bin/pip is an entry file for loading the pip required version module. Somehow when I am upgrading/changing pip installation this file is not getting updated and so I update it manually every time.

Solution 3 - Python

I did not manage to get it to work by using easy_install pip or updating the pip configuration file /usr/local/bin/pip.

Instead, I removed pip and installed the distribution required by the conf file:

> Uninstalling pip:

$ sudo apt purge python-pip or $ sudo yum remove python-pip

> Reinstalling required distribution of pip (change the distribution accordingly):

$ sudo easy_install pip==9.0.3

Solution 4 - Python

Delete all of the pip/pip3 stuff under .local including the packages.

sudo apt-get purge python-pip python3-pip

Now remove all pip3 files from local

sudo rm -rf /usr/local/bin/pip3

you can check which pip is installed other wise execute below one to remove all (No worries)

sudo rm -rf /usr/local/bin/pip3.*

Using pip and/or pip3, reinstall needed Python packages.

sudo apt-get install python-pip python3-pip

Solution 5 - Python

After upgrading from 18.0 to 18.1, I got the same error. Reinstalling the program(without using pip itself) worked for me:

$ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
$ sudo python get-pip.py

Solution 6 - Python

On mac this can be fixed with brew

brew reinstall python

Solution 7 - Python

if you have 2 versions of pip for example /usr/lib/pip and /usr/local/lib/pip belongs to python 2.6 and 2.7. you can delete the /usr/lib/pip and make a link pip=>/usr/local/lib/pip.

Solution 8 - Python

Just relink to resolve it. Find which python : ls -l /usr/local/bin/python

ln -sf /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/pip /usr/local/bin/pip

Or reinstall pip: https://pip.pypa.io/en/stable/installing/

Solution 9 - Python

This is an issue with Homebrew that occurs when upgrading pip. Working off the answer by @amangpt777, the following worked for me! 拾

You can still access pip by using python -m pip. Hence, you can get your pip version by running:

python -m pip --version

Copy the version and update the following files with the new version:

/usr/local/opt/[email protected]/bin/pip3
/usr/local/opt/[email protected]/bin/pip3.x

They should look something like this:

#!/usr/local/opt/[email protected]/bin/python3.7
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==21.3.1','console_scripts','pip3.7'
__requires__ = 'pip==21.3.1'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('pip==21.3.1', 'console_scripts', 'pip3.7')()
    )

And you should be able to use pip normally again!

Solution 10 - Python

A bit late but if easy_install doesn't solve the issue, this worked fine for me:

$ vim /usr/local/bin/pip

Then run:

:%s/7\.1\.0/8\.1\.1/g
:wq

Solution 11 - Python

After a large upgrade in Mint -> 19, my system was a bit weird and I came across this problem too.

I checked the answer from @amangpt777 that may be the one to try

/usr/local/bin/pip # -> actually had a shebang calling python3

~/.local/bin/pip* # files were duplicated with the "sudo installed" /usr/local/bin/pip*

Running

sudo python get-pip.py # with script https://bootstrap.pypa.io/get-pip.py
sudo -H pip install setuptools

seem to solve the problem. I understand this as a problem with the root / user installation of python. Not sure if ananconda3 is also messing around with those scrips.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArnold LaishramView Question on Stackoverflow
Solution 1 - PythonAlex CollinView Answer on Stackoverflow
Solution 2 - Pythonamangpt777View Answer on Stackoverflow
Solution 3 - Pythonuser5305519View Answer on Stackoverflow
Solution 4 - PythonAseem SrivastavaView Answer on Stackoverflow
Solution 5 - Pythonsdempsey13View Answer on Stackoverflow
Solution 6 - PythonSardorbek ImomalievView Answer on Stackoverflow
Solution 7 - PythondasonsView Answer on Stackoverflow
Solution 8 - Pythonzhi.yangView Answer on Stackoverflow
Solution 9 - PythonAarni AlasaarelaView Answer on Stackoverflow
Solution 10 - PythonGane D. GeoffreyView Answer on Stackoverflow
Solution 11 - PythonGildasView Answer on Stackoverflow