Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

ipython - What is causing ImportError: No module named pkg_resources after upgrade of Python on os X?

I just updated Python to 2.6.4 on my Mac. I installed from the dmg package.

The binary did not seem to correctly set my Python path, so I added '/usr/local/lib/python2.6/site-packages' in .bash_profile

>>> pprint.pprint(sys.path)  
['',
'/Users/Bryan/work/django-trunk', 
'/usr/local/lib/python2.6/site-packages',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',  
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages']

Apparently that is not all the required paths because I can't run iPython.

$ ipython  
Traceback (most recent call last):  
  File "/usr/local/bin/ipython", line 5, in <module>  
  from pkg_resources import load_entry_point  
ImportError: No module named `pkg_resources`

I've done Google searches and I can't really figure out how to install pkg_resources or make sure it's on the path.

What do I need to do to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I encountered the same ImportError. Somehow the setuptools package had been deleted in my Python environment.

To fix the issue, run the setup script for setuptools:

curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python

If you have any version of distribute, or any setuptools below 0.6, you will have to uninstall it first.*

See Installation Instructions for further details.


* If you already have a working distribute, upgrading it to the "compatibility wrapper" that switches you over to setuptools is easier. But if things are already broken, don't try that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...