While python comes standard on the Mac, I tend to also install the latest python using MacPorts so that I can get a whole python tree with numpy, scientificpython, ipython, etc. and not touch the default OS X python install.

For the most part this just involves a couple of incantations and setting a couple of aliases in my .profile file

alias python="/opt/local/bin/python2.5"
alias ipython="/opt/local/bin/ipython2.5"

For the most part this works well, and having my PYTHONPATH environmental variable (again set in my .profile) to include my local python module directory works well.

export PYTHONPATH=$PYTHONPATH:/Users/{username}/library/python

One problem that I have is that while vi(m) is my editor of choice, in some cases I like to code in TextWrangler, and I would like to be able to hit Command-R and have the script run. What then happens is that TextWrangler uses the standard /usr/bin/python, which for some weird reason would not read in my PYTHONPATH.

What I finally did was to create a user.pth file and put this in

/Library/Python/2.5/site-packages/

Probably not the most eloquent solution but it worked.

Technorati Tags:
,

Advertisements