failed in "sudo pip"

12,269

Solution 1

I had the same problem.

  1. sudo which pip

  2. sudo vim /usr/bin/pip

  3. modify any pip==6.1.1 to pip==8.1.2 or the version you just upgrade to.

It works for me.

Solution 2

Try this:

sudo easy_install --upgrade pip

By executing this you are upgrading the version of pip that sudoer is using.

Solution 3

if you have 2 versions of pip for example /user/lib/pip and /user/local/lib/pip belongs to python 2.6 and 2.7. you can delete the /user/lib/pip and make a link pip=>/user/local/lib/pip.
you can see that the pip commands called from "pip" and "sudo" pip are different. make them consistence can fix it.

Share:
12,269
Admin
Author by

Admin

Updated on July 20, 2022

Comments

  • Admin
    Admin almost 2 years

    Please help me.

    • server : aws ec2
    • os : amazon linux
    • python version : 2.7.10
    $ pip --version
    pip 7.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
    

    It's OK.
    But...

    $ sudo pip --version
    Traceback (most recent call last):
      File "/usr/bin/pip", line 5, in 
        from pkg_resources import load_entry_point
      File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in 
        working_set = WorkingSet._build_master()
      File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 616, in _build_master
        return cls._build_from_requirements(__requires__)
      File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 629, in _build_from_requirements
        dists = ws.resolve(reqs, Environment())
      File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 807, in resolve
        raise DistributionNotFound(req)
    pkg_resources.DistributionNotFound: pip==6.1.1
    
  • herve
    herve over 7 years
    You may have to sudo vim /usr/bin/pip-2.7 or pip-3.5