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

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

  • Which of the questions here have yo tried and how did they fail - note just look at ones for Mavericks e.g. apple.stackexchange.com/questions/106355/… or apple.stackexchange.com/questions/107787/… etc. We want to have one question for this not multiple with different answers – mmmmmm May 8 '14 at 15:40
  • Which GUI application needs to get a variable from the filesystem? – bmike May 8 '14 at 15:40
  • The first link specific details how to set the PATH variable, a very specific environment variable, but unfortunately very different from a generic environment variable like PYTHONPATH. The second like is more helpful. He says that launched.conf is still supported. This is good news and is one of the files that I tried setting previously. Perhaps my syntax is wrong. Can anyone verify it? Here is what my file looks like: setenv PYTHONPATH ~/Documents/CrowdSurfer – Nick May 8 '14 at 16:03
  • Until your accounts get merged, just edit the post to explain how the linked answers don't make sense or solve your specific issue. No need to tack on edit: at the end of the post - just make the words flow with the new data included as best fits. – bmike May 8 '14 at 17:05
  • Also for PYTHONPATH a better way is use Python specific setups e.g. vurtualenv – mmmmmm May 10 '14 at 17:13

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


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
  • Could you expand on what each part of this does? A block of code like this isn't really self-explanatory to most users – grg May 8 '14 at 18:12
  • 1
    @grgarside : Thank you for your suggestion. Please let me know if more explaination is required. Thanks again. – chillin May 8 '14 at 19:53
  • that will do it – Ruskes May 8 '14 at 19:53
  • 4
    How does this set the variable for GUI applications (started via Finder)? – nohillside May 8 '14 at 19:59
  • 2
    @chillin - This is the issue in OSX environment variables cannot be set for GUIS and command line in the same way. In command line it is a simple edit of profile files GUI has to be done another way – mmmmmm May 10 '14 at 17:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .