1

There is a lot of information on Stack Overflow about how to set environment variables (like this question and this one). Unfortunately it seems that Apple has been playing with this process a lot over the last few years and so much of the discussion online seems to have been rendered obsolete by Mountain Lion and Mavericks. There are two methods discussed in more recent posts: editing launchd.conf and modifying ~/.MacOSX/environment.plist. I've tried both and am still not getting my new environment variable everywhere I want.

I've boiled the problem down to this bit of AppleScript:

set pp to system attribute "PYTHONPATH"
display dialog pp buttons {"OK"} default button 1

When I run the code from the AppleScript editor it gives me a non-empty PYTHONPATH, which is what I want (I'm trying to set the PYTHONPATH variable for scripts run from places other than terminal windows). But when I run the same script from Quicksilver (which is really where I'd like it to work), it gives me an empty Python path. Can I set PYTHONPATH in a way that will show up both places?

Community
  • 1
  • 1
kuzzooroo
  • 6,788
  • 11
  • 46
  • 84
  • 1
    How did you get your definition of `PYTHONPATH` into the environment to begin with? (That is, why is the AppleScript Editor succeeding?) I suspect you set it in the `launchd` environment, perhaps with `launchctl`. If so, you may just need to restart Quicksilver (e.g. by logging out and back in) for it to inherit the new variable. The environment is inherited when a process starts but after that can't be modified except by the process itself, so changes elsewhere won't affect it. – Ken Thomases Feb 23 '14 at 21:31
  • Ugh, you are right. Operator error. I restarted my machine several times as I was trying this or that solution, but apparently I missed it here. Thanks. BTW, I did _both_ `launchd.conf` _and_ `environment.plist`. Tonight I'll try to figure out which was necessary; presumably it will be the `launchd` one. – kuzzooroo Feb 24 '14 at 13:06

1 Answers1

0

The answer was to edit launchd.conf and then restart. This answer claims to tell you how to do it without a restart, but it didn't work for me.

The answer is different under Yosemite. See these two pages:

  1. https://apple.stackexchange.com/a/106814/60655
  2. Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?
Community
  • 1
  • 1
kuzzooroo
  • 6,788
  • 11
  • 46
  • 84