The 'pip==7.1.0' distribution was not foun

2019-01-23 01:37发布

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.

7条回答
疯言疯语
2楼-- · 2019-01-23 02:17

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/

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-23 02:19

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.

查看更多
乱世女痞
4楼-- · 2019-01-23 02:22

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

查看更多
再贱就再见
5楼-- · 2019-01-23 02:24

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.

查看更多
Explosion°爆炸
6楼-- · 2019-01-23 02:26

I repaired mine this with command:

easy_install pip

查看更多
乱世女痞
7楼-- · 2019-01-23 02:31

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
查看更多
登录 后发表回答