我使用python 3.6
构建了一个简单的web scraper脚本scraper.py
,当我从终端执行时,它运行得很好。现在我想在登录计算机时自动运行它,所以我写了一个简单的scraper_launcher.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>scraper.job</string>
<key>ProgramArguments</key>
<array>
<string>./Users/me/Desktop/scraperFolder/scraper.py</string>
</array>
<key>StandardErrorPath</key>
<string>Users/me/Library/Logs/Errors/scraper.error</string>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
在我的Users/me/Library/LaunchAgents/
文件夹中。在
我遇到的第一个问题是,在执行launchctl load scraper_launcher.plist
时,macOs在默认情况下似乎使用python 2.7
,而脚本失败。为了解决这个问题,我尝试在scraper.py
的开头添加shabang,指定python版本:#!/usr/bin/env python3
。在
现在,当我在终端上执行./scraper.py
时,一切仍然正常,但是当我执行launchctl load scraper_launcher.plist
时,我得到了以下错误:
env: python3: No such file or directory
。在
我错过了什么?{12}有。在
PS:当然我可以将scraper.py
重新编码为python 2.7
,但这不是重点,我想让它按原样工作并理解为什么要使用scraper_启动器.plist是在犯这样的错误。在
目前没有回答
相关问题 更多 >
编程相关推荐