简体   繁体   English

启动失败,无法使用phantomJS运行python脚本

[英]launchd failing to run python script with phantomJS

I have a python script that does some things online. 我有一个python脚本,可以在线做一些事情。 Every 10 seconds launchd (OSX 10.11.3 El Capitan) launches a shell script, which calls the python script, which goes online using selenium webdriver.PhantomJS() (or should). 每10秒钟启动一次(OSX 10.11.3 El Capitan),就会启动一个称为python脚本的shell脚本,该脚本使用selenium webdriver.PhantomJS()(或应该)联机。

When running the shell script from the terminal, everything succeeds. 从终端运行shell脚本时,一切都会成功。 When running in the configuration described above but with webdriver.Firefox() instead of webdriver.PhantomJS(), everything succeeds. 当以上述配置运行但使用webdriver.Firefox()而不是webdriver.PhantomJS()时,一切都会成功。 However, when running through launchd -> shell -> python with webdriver.PhantomJS(), it exits with abnormal code: 1. 但是,当使用webdriver.PhantomJS()运行launchd-> shell-> python时,它以异常代码退出:1。

A simplified version of my code (with all the imports): 我的代码的简化版本(包含所有导入):

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

What am I missing? 我想念什么? I would suspect full path names, but I do not explicitly import Firefox() either, and that does work... 我怀疑是完整的路径名,但我也没有明确导入Firefox(),这确实有用......

Is it failing on an import failure? 是否由于导入失败而失败? I had a similar-sounding problem, outlined here: Running Python Script with Launchd: imports not found 我有一个类似的问题,在这里概述: 使用Launchd运行Python脚本:找不到导入

What was helpful: using LaunchControl, capturing Standard Error, and finding out python could not import a specific package. 有用的是:使用LaunchControl,捕获标准错误,并找出python无法导入特定的包。 Not sure if that's your problem, but Standard Error will tell you what abnormal code: 1 actually is. 不确定这是不是你的问题,但标准错误会告诉你什么是异常代码:1实际上是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM