jamiet
jamiet

Reputation: 12264

easy_install fails, can't find setuptools

I have a downloaded .egg file that I'd like to easy_install. So I issue: easy_install my.egg and it fails with:

$ which easy_install
/usr/local/opt/python2/libexec/bin/easy_install    
$ easy_install my.egg
Traceback (most recent call last):
      File "/usr/local/opt/python2/libexec/bin/easy_install", line 6, in <module>
        from pkg_resources import load_entry_point
      File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3195, in <module>
        @_call_aside
      File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3179, in _call_aside
        f(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3208, in _initialize_master_working_set
        working_set = WorkingSet._build_master()
      File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 683, in _build_master
        return cls._build_from_requirements(__requires__)
      File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 696, in _build_from_requirements
        dists = ws.resolve(reqs, Environment())
      File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 885, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'setuptools==38.5.1' distribution was not found and is required by the application

So I try pip setuptools which also fails:

$ pip setuptools
Traceback (most recent call last):
  File "/usr/local/opt/python2/libexec/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3195, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3179, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3208, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 683, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 696, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 885, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==9.0.1' distribution was not found and is required by the application

I don't know how pip can have gotten into a state where it won't work however I found https://stackoverflow.com/a/43311811/201657 which led me to discover that I have another pip at /usr/local/bin/pip :

$ /usr/local/bin/pip --version
pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)

So I try with that:

$ /usr/local/bin/pip install setuptools
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/site-packages

I confess I haven't a clue what's going on here, or how to fix it. I'm a bit of a python noob I'm afraid. Some pointers would be handy. How can I successfully run easy_install my.egg?

I'm on macOS by the way.

Upvotes: 1

Views: 1335

Answers (1)

Kevin Katzke
Kevin Katzke

Reputation: 3761

Executing:

sudo easy_install pip

should solve this issue. After pip is fixed you can go on downloading the other packages.

Upvotes: 1

Related Questions