Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip broken, reinstall doesn't work. EC2

I am using pip on EC2 now, python version is 2.7. 'sudo pip' suddenly doesn't work anymore.

[ec2-user@ip-172-31-17-194 ~]$ sudo pip install validate_email
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 3138, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3124, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3151, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 663, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 676, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 849, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application
[ec2-user@ip-172-31-17-194 ~]$ which pip
/usr/local/bin/pip
like image 927
Marshall X Avatar asked Jan 12 '16 02:01

Marshall X


People also ask

Can not found pip?

The pip: command not found error is raised if you do not have pip installed on your system, or if you've accidentally used the pip command instead of pip3. To solve this error, make sure you have installed both Python 3 and pip3 onto your system.


2 Answers

first, which pip is not going to return the same result as sudo which pip, so you should check that out first.

you may also consider not running pip as sudo at all. Is it acceptable & safe to run pip install under sudo?

second, can you try this:

easy_install --upgrade pip

if you get an error here (regarding pip's wheel support), try this, then run the above command again:

easy_install -U setuptools
like image 188
wesm Avatar answered Oct 02 '22 16:10

wesm


I fixed the same error ("The 'pip==6.1.1' distribution was not found") by using the tip of Wesm :

$> which pip && sudo which pip
/usr/local/bin/pip
/usr/bin/pip

So, it seels that "pip" of average user and of root are not the same. Will fix it later.

Then I ran "sudo easy_install --upgrade pip" => succeed

Then I used "sudo /usr/local/bin/pip install " and it works.

like image 34
JayMore Avatar answered Oct 02 '22 17:10

JayMore