我想写一个python脚本,在我的Mac中每天调用'brew update'。 下面是python脚本和启动plist。在
#!/usr/local/bin/python
import subprocess
# update homebrew and check outdated package
subprocess.call(["brew", "update"])
subprocess.call(["brew", "outdated"])
subprocess.call(["brew", "doctor"])
.plist公司
^{pr2}$当我使用launchd load the plist文件运行时,会出现如下相同的错误:
Traceback (most recent call last):
File "/Users/wuchangxi/Workspace/scripts/jobs/daily.py", line 5, in <module>
subprocess.call(["brew", "update"])
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
如果直接在shell中运行python脚本,它会很好地工作。但是当调用.plist时,没有这样的文件错误。在
我怀疑这是因为启动的环境没有设置与您自己shell中的路径相匹配的路径
您可能需要将绝对路径传递给brew二进制文件,或在plist中设置一个包含要使用的路径的环境节
相关问题 更多 >
编程相关推荐