![](/img/trans.png)
[英]Getting a status 78 launchctl when trying to run a python script with launchd
[英]Run Python script on launchctl - error 127
因此,我试图通过osx上的LaunchAgents运行脚本,并且我不断退出服务并返回异常代码:127错误。
当我在终端中运行脚本时,一切正常(它只是打开浏览器选项卡的测试脚本)。 我已经验证了.plist文件,但是这里是:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.restart</string>
<key>Program</key>
<string>/Users/flp/PythonScripts/run.py</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
这是脚本:
#! /usr/bin/env python3
import webbrowser
a_website = "https://www.abola.pt"
# Open url in a new window of the default browser, if possible
webbrowser.open_new(a_website)
这是launchctl的日志:
com.apple.xpc.launchd[1] (local.restart[3080]): Service exited with abnormal code: 127
难道我做错了什么?
问题出在shebang。 编译器路径不正确,对其进行了修复,并按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.