0

I have run into this numerous times on my current project and it's driving me crazy. I discover I need to install some module but get an error that pip 6.1.1 isn't installed (server has 8.1.2):

$ sudo pip install djangorestframework
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2991, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2977, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 664, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 677, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 856, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application

so I checked:

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

I have tried $ sudo yum install djangorestframework but the package doesn't exist (no surprise). how do install these things that seem to rely specifically on 6.1.1 but I have 8.1.2? I'm worried if I uninstall (and rollback) that I'll loose functionality in other areas...

It occurred to me it's a difference between the sudo in the first command and lack of it in the second, so I tried this:

$ sudo yum install python-pip
Loaded plugins: priorities, update-motd, upgrade-helper
Package python26-pip-6.1.1-1.23.amzn1.noarch already installed and latest version
Nothing to do
[ec2-user@ip-172-XX-XX-XXX limboproj]$ source limboenv/bin/activate
(limboenv)[ec2-user@ip-172-XX-XX-XXX limboproj]$ sudo yum install python-pip
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest                                              | 2.1 kB     00:00
amzn-updates/latest                                           | 2.3 kB     00:00
Package python26-pip-6.1.1-1.23.amzn1.noarch already installed and latest version
Nothing to do

and I still get:

$ sudo pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2991, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2977, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 664, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 677, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 856, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application

SO labelled as a duplicate, so I'm including here my comment below. when I tried to follow the answer on the suggested question, I got:

$ sudo pip install --upgrade pip-6.1.1 

which results in a stacktrace ending with:

The 'pip==6.1.1' distribution was not found and is required by the application. also notice in my edit, i show that sudo yum install python-pip seems to conflict with sudo pip --version
Keith
  • 777
  • 8
  • 27
  • Possible duplicate of [How can I install a specific version of pip via easy-install? - Mac OS Mavericks](http://stackoverflow.com/questions/25942386/how-can-i-install-a-specific-version-of-pip-via-easy-install-mac-os-mavericks) – maxymoo Oct 31 '16 at 04:20
  • good thought, but doesn't resolve. as-per those answer, `]$ sudo pip install --upgrade pip-6.1.1` results in : `The 'pip==6.1.1' distribution was not found and is required by the application`. also notice in my edit, i show that `sudo yum install python-pip` seems to conflict with `sudo pip --version` – Keith Oct 31 '16 at 04:23
  • try `sudo pip install pip==6.1.1` – maxymoo Oct 31 '16 at 04:32
  • @maxymoo, stacktrace ends with `The 'pip==6.1.1' distribution was not found and is required by the application` – Keith Oct 31 '16 at 04:36
  • If you do a local installation of `pip` into `/usr/local/lib`, AND use a system level pip package at the same time, you are going to have a bad time like so. Try running `pip -V` and note where the offending version information are coming from. – metatoaster Oct 31 '16 at 04:57
  • Packages generally shouldn't require a specific version of `pip` (most don't use `pip` as a library), and `djangorestframework` lists [no requirements](https://github.com/tomchristie/django-rest-framework/blob/3.5.1/setup.py#L89). This isn't a solution to the problem you presented, but it does suggest that your `pip` version is not the core issue here. – jonafato Oct 31 '16 at 22:13

1 Answers1

0

not sure how to really resolve what I was dealing with, but it turns out the project's virtualenv had a satisfactory version of pip. for people in the future, try to activate the virtual env:

$ source projectenv/bin/activate

and then install

$ sudo pip install djangorestframework

That worked great for me

Keith
  • 777
  • 8
  • 27