System environment is different between AppleScript editor and running my script standalone under Mac OS Mavericks

StackOverflow https://stackoverflow.com/questions/21972753

Question

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?

Was it helpful?

Solution

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?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top