AppleScript 编辑器和在 Mac OS Mavericks 下独立运行我的脚本之间的系统环境不同 [英] System environment is different between AppleScript editor and running my script standalone under Mac OS Mavericks

查看:12
本文介绍了AppleScript 编辑器和在 Mac OS Mavericks 下独立运行我的脚本之间的系统环境不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Stack Overflow 上有很多关于如何设置环境变量的信息(例如 这个问题这个问题).不幸的是,在过去的几年里,Apple 似乎一直在玩这个过程,网上的很多讨论似乎都被 Mountain Lion 和 Mavericks 淘汰了.最近的帖子中讨论了两种方法:编辑launchd.conf 并修改 ~/.MacOSX/environment.plist.我已经尝试了这两种方法,但仍然没有在我想要的任何地方获得我的新环境变量.

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.

我将问题归结为 AppleScript 的这一点:

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

当我从 AppleScript 编辑器运行代码时,它给了我一个非空的 PYTHONPATH,这正是我想要的 (我正在尝试为从终端窗口以外的地方运行的脚本设置 PYTHONPATH 变量).但是当我从 Quicksilver 运行相同的脚本时(这正是我希望它工作的地方),它给了我一个空的 Python 路径.我可以以同时显示两个地方的方式设置 PYTHONPATH 吗?

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?

推荐答案

答案是编辑launchd.conf和然后重新启动.这个答案声称会告诉您如何在不重新启动的情况下进行操作,但它对我不起作用.

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.

Yosemite 下的答案是不同的.看这两页:

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

  1. https://apple.stackexchange.com/a/106814/60655
  2. 通过 launchd.conf 设置环境变量不再适用于 OS X Yosemite/El Capitan/macOS Sierra?

这篇关于AppleScript 编辑器和在 Mac OS Mavericks 下独立运行我的脚本之间的系统环境不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆