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.
September 17, 2009 at 6:16 am
I am currently trying to get the TextWrangler hash menu to run my python scripts, but am having the same problem. Did you ever find a better way of getting it to read your PYTHONPATH?
September 17, 2009 at 1:27 pm
Hey Will,
you know, I never did. I’ve since moved over to MacVIM for the most part from TextWrangler so I never followed up on this.
If you do find something please let me know and we’ll post it!
Thanks
September 21, 2009 at 5:25 am
Thanks for the reply — I actually did successfully get it flying by using the environment.plist file to set PYTHONPATH and PYTHONHOME, as described here:
http://developer.apple.com/mac/library/qa/qa2001/qa1067.html
I’ll have to check out MacVIM…
September 21, 2009 at 6:46 am
Thanks for the follow up! MacVim is pretty cool since I’m familiar with vi/vim, but TextWrangler did the job as well, just more mouse-based it seemed to me.
Good luck with it!