【问题标题】:launchd failing to run python script with phantomJSlaunchd 无法使用 phantomJS 运行 python 脚本
【发布时间】:2016-03-13 10:36:39
【问题描述】:

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

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

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

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

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

【问题讨论】:

  • 我也有同样的问题。我什至无法通过加载 PhantomJS 的行。 :(

标签: python selenium phantomjs launchd


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-10
    • 1970-01-01
    • 2015-03-29
    • 2018-10-23
    • 2016-06-18
    • 2017-12-06
    • 1970-01-01
    相关资源
    最近更新 更多