launchd无法使用phantomJS运行python脚本

时间:2016-03-13 10:36:39

标签: python selenium phantomjs launchd

我有一个在线做一些事情的python脚本。每10秒启动一次(OSX 10.11.3 El Capitan)启动一个shell脚本,该脚本调用python脚本,该脚本使用selenium webdriver.PhantomJS()(或应该)联机。

从终端运行shell脚本时,一切都成功。当在上面描述的配置中运行但是使用webdriver.Firefox()而不是webdriver.PhantomJS()时,一切都成功了。但是,当通过launchd运行时 - > shell - >使用webdriver.PhantomJS()的python,它以异常代码退出:1。

我的代码的简化版本(包含所有导入):

from selenium import webdriver
import selenium.webdriver.support.ui as ui
from selenium.common.exceptions import  NoSuchElementException
d = webdriver.PhantomJS()
d.close()

我错过了什么?我怀疑是完整的路径名,但我也没有明确导入Firefox(),这确实有用......

1 个答案:

答案 0 :(得分:0)

导入失败是否失败?我有一个类似的问题,在这里概述:Running Python Script with Launchd: imports not found

有用的是:使用LaunchControl,捕获标准错误,找出python无法导入特定的包。不确定这是否是您的问题,但标准错误会告诉您异常代码:1实际上是。