【发布时间】:2019-12-24 21:02:21
【问题描述】:
所以我试图让我的 Excel 电子表格中的一个按钮启动 Python 脚本。显然这只能在 Windows 上实现,所以在 Mac 版本上,人们有一个解决方法,他们使用 Excel 启动 AppleScript,然后启动 Python 脚本。
在 Automator 中,我尝试选择应用程序,但当它不起作用时,我选择了快速操作,并且两次都插入了“运行 Shell 脚本”模块。
在其中我将 Shell 设置为“usr/bin/python”并将输入作为“As Arguments”传递。然后在我输入的文本字段中
do shell script "/Users/user_name/Desktop/integrationtest.py"
我试过了
do shell script "python /Users/user_name/Desktop/integrationtest.py"
当我点击 Automator 右上角的运行时,它会显示
The action “Run Shell Script” encountered an error: “ File "<string>", line 1
do shell script "/Users/user_name/Desktop/integrationtest.py"
^
SyntaxError: invalid syntax”
File "<string>", line 1
do shell script "/Users/user_name/Desktop/integrationtest.py"
^
SyntaxError: invalid syntax
不太确定我做错了什么 - 有什么想法吗?感谢您的帮助
【问题讨论】:
-
我会指出 Automator 有一个 Run Shell Script 操作,这可能比尝试在 AppleScript 中从
do shell script运行 shell 脚本提供更好的结果。不过,我并不是很喜欢 Excel 按钮,所以我稍后会研究一下。
标签: macos terminal applescript automator