Setting up your PYTHONPATH environment variable globally on OSX

Here’s another time-saver for OSX users. Don’t use environment.plist for global environment variables!

When you want to add locations to your Python path, you have a couple of different options. Ryan talked about this in greater detail on his site, so I won’t go into the details for all of these. If you want to permanently add locations to your path, you have three general alternatives:

  1. Use sys.path.append() in your userSetup.py file
  2. Set the value for PYTHONPATH in your maya.env file
  3. Set the value for PYTHONPATH at the system level


Autodesk’s documentation
can help you figure out the first two methods reasonably well, and they work fine for most situations. However, if you have locations you want to use with Maya as well as other interpreters, the third option may be helpful. While doing this on Windows is relatively easy, it is a little painful on Mac OSX.

Most Google searching will send you to some variation on this technique, whereby you create an environment.plist file containing the value for your PYTHONPATH variable and place it in a folder ~/.MacOSX. Maybe this will work for you, but maybe it won’t. It didn’t work for me. What’s the problem?

Apparently, when you start an application from Spotlight as opposed to Finder, it has a different parent process—one that does not use the environment.plist file. I have gotten used to using Spotlight to start all of my applications and to perform the majority of my menu operations because it saves me huge amounts of time while working (and I don’t want to have to remember where stuff is). Fortunately, there is a fix that will ensure your environment variables will be properly set in all contexts. I suggest you read about the details if you are interested, but if you just want to work then use the following solution:

  1. If you do not have a launchd.conf file in /etc then create one
  2. Edit launchd.conf to contain a line like this: setenv PYTHONPATH /Users/Shared/Autodesk/maya/scripts
  3. Reboot

You can now confirm that this has worked by opening Terminal from Spotlight and entering the set command.

Tags: , , , ,

Leave a Reply