我已经在我的机器上安装了 Py-Appscript,它可以与 /Library/Frameworks/Python.framework/Versions/Current/bin/python
中的 Python 安装一起使用。
我正在尝试将 Py-Appscript 的安装与 Automator 服务一起使用。为此,我使用运行 Shell 脚本操作,然后将Shell设置为usr/bin/python
(这是我的唯一选择)不幸的是,Python)。
usr/bin/python
似乎无法访问我的第三方模块并崩溃:
from appscript import *
我有办法给usr/bin/python
访问我的第三方模块?
或者
有没有办法告诉 Automator 使用 /Library/Frameworks/Python.framework/Versions/Current/bin/python
代替?
我需要 Automator 直接从 运行 Shell 脚本 操作运行 Python。任何调用 Automator 外部的 Python 脚本(例如通过 bin/bash)的操作都不会执行得足够快而无用。
I have installed Py-Appscript on my machine and it can be used with the Python installation at /Library/Frameworks/Python.framework/Versions/Current/bin/python
.
I am trying to use this installation of Py-Appscript with an Automator service. To do this, I use the Run Shell Script action and then set the Shell to usr/bin/python
(which is my only choice for Python, unfortunately).
The usr/bin/python
does not appear to have access to my third-party modules and crashes on the line:
from appscript import *
Is there a way for me to give usr/bin/python
access to my third-party modules?
OR
Is there a way to tell Automator to use /Library/Frameworks/Python.framework/Versions/Current/bin/python
instead?
I need Automator to run the Python directly from the Run Shell Script action. Any action that calls Python scripts that are external to Automator (via bin/bash
, for example) does not perform quickly enough to be useful.
发布评论
评论(2)
好的,我可以使用 如何在 Mac OS X 上将 PHP shell 脚本作为 Automator 操作执行。
在 Run Shell Script 操作中,我使用了
/bin/sh/
shell 和< ...
EOF
到正确的 Python 安装。例如,输入
“运行 Shell 脚本”操作的代码部分即可。因此,人们可以调用正确的安装(上面的
/Library/Frameworks/Python.framework/Versions/Current/bin/python
)并将其程序放在< ...
EOF
分隔符。阿尔弗雷德
这个技巧也适用于阿尔弗雷德。如果您想将
appscript
与 Alfred 一起使用,只需确保将{query}
传递给上面的 python 版本,如下所示:Okay, I was able to get it working using a hack found at How do I execute a PHP shell script as an Automator action on Mac OS X.
Inside of the Run Shell Script action, I used the
/bin/sh/
shell with<<EOF
...EOF
to the proper Python installation.So for example, entering
Into the code section of the Run Shell Script action will work. So one can call the proper installation (
/Library/Frameworks/Python.framework/Versions/Current/bin/python
above) and put their program between the<<EOF
...EOF
delimeters.Alfred
This trick works with Alfred also. If you want to use
appscript
with Alfred, just make sure that you pass{query}
to the python version above, like this:安装模块时,通常会为每个 Python 实例安装它们。因此,在这种情况下,您已将它们安装在 /Library/Frameworks/Python.framework/Versions/Current/bin/python 中的 Python 中,然后它将仅适用于该 Python。 /usr/bin/python 显然是另一个 Python 安装(我不是 OS X 专家)。
要使其可用于 /usr/bin/python 安装,请将其安装到 /usr/bin/python。
When you install modules, you typically install them per Python instance. So in this case you have installed them for the Python in /Library/Frameworks/Python.framework/Versions/Current/bin/python, and it will then be available only for that Python. /usr/bin/python is then apparently another Python installation (I'm not an OS X expert).
To make it available for the /usr/bin/python installation, install it for /usr/bin/python.