Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use pip anymore

Tags:

python

pip

When I try to use pip, I met this error:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==1.0.2', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.6/dist-packages/distribute-0.6.21-py2.6.egg/pkg_resources.py", line 337, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.6/dist-packages/distribute-0.6.21-py2.6.egg/pkg_resources.py", line 2281, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.6/dist-packages/distribute-0.6.21-py2.6.egg/pkg_resources.py", line 1996, in load
    raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'pip' from '/usr/lib/pymodules/python2.6/pip/__init__.pyc'> has no 'main' attribute

Obviously, I made some change to the system that broke pip. But I've no idea what it is. What might cause the exception above?

Edit:

What I can guess is that this morning, I crated a virtualenv, installed a package written by myself by running:

python setup.py install

in that environment.

BTW, I did try to reinstall pip by running get-pip.py, didn't work

like image 730
ablmf Avatar asked Aug 20 '11 19:08

ablmf


People also ask

Is there any alternative for pip?

00:40 Other alternatives are Pipenv and Poetry. Like Conda, these tools merge virtual environments and package management into a single utility. Pipenv aims to bring the best of all packaging worlds to Python.

Why is pip not working Mac?

Sometimes when you are installing packages, you might face the error: pip: command not found . This error could be due to the following reasons: Pip is not installed. Pip is installed, but it is not compatible with the current environment.

How do I force reinstall pip?

To force re-download use the --no-cache-dir flag. Note that this command also reinstalls all dependencies. Add --no-deps to avoid that, as suggested in Finn's answer below.

How do you fix a broken pip?

If pip is broken after an attempted upgrade to a newer version, try the following: Download get-pip.py and "Save As" the file using right-click. Open a command prompt as an administrator. cd to the path where you saved the file, in my case cd C:\Users\xyz\Downloads> then type python get-pip.py .


2 Answers

Reinstall using easy_install. Close the terminal and reopen. Pip should now work.

like image 37
TDNS Avatar answered Sep 29 '22 11:09

TDNS


I note that distribute is installed in /usr/local but pip is in /usr/lib, so I'm guessing that you have an older version of pip installed system wide that is somehow overriding what you're easy_installed or piped. I'd start looking there.

like image 183
Ross Patterson Avatar answered Sep 29 '22 11:09

Ross Patterson