running Panda from IDE on a Mac

This isn’t a question, but rather me reporting something I figured out that other people might find useful.

I’m using Panda on OSX using pro-rsoft’s just released package. His dmg includes a script that’ll automatically set some environment variables in your .bash_profile so that Panda will run correctly. With those .bash_profile settings, you can launch Panda from Terminal just by typing “python” in the terminal window.

Now that’s pretty great, but one minor inconvenience that was bugging me was that Panda wasn’t working when I clicked Run in my IDE. Well I did a bit of snooping online, and what I realized is that .bash_profile only applies to Terminal. To set environment variables to use with GUI applications (like an IDE) you need to put those settings in your environment.plist file. Refer to this page on Apple’s developer site:

Once I had put the paths into environment.plist (and relogged so that the changes would take affect; that threw me for a bit :stuck_out_tongue:) I could run Panda programs just by clicking Run in my IDE. woo

To edit your environment.plist, click Go To Folder in the Finder’s Go menu and type in ~/.MacOSX/ (if this folder doesn’t exist yet, that developer page above mentions how to create it.) Use the PropertyListEditor app in Developer tools (/Developer/Applications/Utilities/PropertyListEditor) and add the following items to the list:

key: PATH string: /Applications/Panda3D/1.6.0/bin:$PATH
key: PYTHONPATH string: /Applications/Panda3D/1.6.0/lib:$PYTHONPATH
key: DYLD_LIBRARY_PATH string: /Applications/Panda3D/1.6.0/lib:$DYLD_LIBRARY_PATH

Incidentally, although this information will apply to any IDE, the editor I was trying to get Panda working in was TextWrangler. TextWrangler is a free Mac application from BareBones Software (they’re best known for BBEdit, and TextWrangler is very similar) that I highly recommend to any Python developers working on a Mac. I had already been using it for months as a great plain text/HTML editor, but I only learned last week that it has programming tools like syntax highlighting and function navigation.

Awesome post. Thanks Joe!

update: I noticed a couple nights ago that I wasn’t able to run everything in Java correctly anymore; some stuff would work, but some things were returning errors. After a couple days of hair pulling, I finally realized the problem was that having an environment.plist could screw up Java if it’s not setup correctly. It was fine before but in the course of figuring out how to get Panda setup I messed it up a bit.

Well, I just figured out how it should be setup. Basically, the paths I have written in my first post overwrite the default path settings rather than append to them. Instead of the strings I listed in my first post, you want these:

key: PATH string: /Applications/Panda3D/1.6.0/bin:/bin:/sbin:/usr/bin:/usr/sbin
key: PYTHONPATH string:/Applications/Panda3D/1.6.0/lib
key: DYLD_LIBRARY_PATH string: /Applications/Panda3D/1.6.0/lib

(note how I’ve added stuff like /usr/bin to PATH. I thought :$PATH would append the default paths, but apparently not.)

Having figured this out, I’m now a little concerned that there are default directories I need to add to PYTHONPATH and DYLD_LIBRARY_PATH. Oh well, at least now if I have problems in the future I know what to look for.