Environment Variables on Mavericks

I am trying to set an environment variable that will be accessible from both a GUI application (Pycharm) as well as from the Terminal. This variable is called PYTHONPATH.

I have tried

  • Setting the system-wide PATH environment variable in Mavericks which doesn't help me because I have to set PYTHONPATH, not PATH
  • How to set system-wide environment variables on OS X Mavericks which gave me the idea to use launched.conf but adding

    setenv PYTHONPATH ~/Documents/CrowdSurfer
    

    doesn't seem to have the desired effect. Maybe I got the syntax wrong here?

Can anyone give me a step by step guide of how to do this correctly on Mavericks?


Solution 1:

Check your current PYTHONPATH setting by opening /Applications/Utilities/Terminal.app and typing the following command and hit the return key:

  echo $PYTHONPATH

Try this alternate syntax in Terminal.app to see if it sets your PYTHONPATH correctly. Recheck the result with the above command again. If so, put the line in your ~/.bash_profile (although a file in /etc/paths.d/ with just the PATH, no commands, ought to set this system-wide).

  export PYTHONPATH=$PYTHONPATH\ : $USER/Documents/CrowdSurfer ; export PYTHONPATH