python phanthomjs is not working with nohup

我怕爱的太早我们不能终老 提交于 2019-12-23 04:47:06

问题


I'm running selenium using phanthomjs, the script is running perfectly if when I trigger it as:

python my_script.py 

But when I try to using nohup:

nohup python my_script.py &

I got the following error:

selenium.common.exceptions.WebDriverException: Message: Service phantomjs unexpectedly exited. Status code was: 8

回答1:


It's probably too late but I just met similar error just with another code and I've found a solution. So, when you run nohup your program's output is redirected to nohup.out, and the file for me was like this:

Traceback (most recent call last):
me/fanar/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running

  File "main.py", line 51, in <module>
    Work()
  File "main.py", line 41, in Work
    TakeImage() # start o 16
  File "main.py", line 9, in TakeImage
    driver = webdriver.PhantomJS()
  File "/home/fanar/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
    self.service.start()
  File "/home/fanar/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 96, in start
    self.assert_process_still_running()
  File "/home/fanar/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service phantomjs unexpectedly exited. Status code was: 1

The workaround was to go to the

.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py

and comment out line

self.assert_process_still_running()



回答2:


Specifying the parameters works for me:

driver = webdriver.PhantomJS(executable_path = '/usr/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs')


来源:https://stackoverflow.com/questions/41668024/python-phanthomjs-is-not-working-with-nohup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!