tags:

views:

2486

answers:

3

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
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?

A: 

While I don't use ipython, there are different versions for python 2.5 and python 2.6. If you haven't already, try upgrading ipython?
See the ipython download page for more info.

Jack M.
+1  A: 

On my system (OSX 10.6) that package is at

/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py

I hope that helps you figure out if it's missing or just not on your path.

Bryan McLemore
+3  A: 

You don't say in your question but I'm assuming you upgraded from the Apple-supplied Python (2.5 on 10.5 or 2.6.1 on 10.6) or that you upgraded from a python.org Python 2.5. In any of those cases, the important point is that each Python instance has its own library, including its own site-packages library, which is where additional packages are installed. (And none of them use /usr/local/lib by default, by the way.) That means you'll need to install those additional packages you need for your new python 2.6. The easiest way to do this is to first ensure that the new python2.6 appears first on your search $PATH (that is, typing python2.6 invokes it as expected); the python2.6 installer should have modified your .bash_profile to put its framework bin directory at the front of $PATH. Then install easy_install using either setuptools or distribute following the instructions there. The pkg_resources module is also automatically installed by this step.

Then use the newly-installed version of easy_install to install ipython.

$ easy_install ipython

It should automatically get installed to the correct site-packages location for that python instance and you should be good to go.

Ned Deily
I messed up when I tried to install setuptools last night.I neglected to finish the installation by running the .egg file as if it were a shell file.$ sh setuptools-0.6c11-py2.6.eggI guess that added the new Python path somewhere.
BryanWheelock