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

冷暖自知 提交于 2019-12-11 06:56:06

问题


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?


回答1:


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?


来源:https://stackoverflow.com/questions/21972753/system-environment-is-different-between-applescript-editor-and-running-my-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!