selenium.common.exceptions.WebDriverException:消息:服务geckodriver意外退出。状态代码为:-11-如何解决?

时间:2018-12-31 15:25:26

标签: python selenium firefox raspberry-pi geckodriver

我想在我的Raspberry Pi Zero W上设置https://github.com/mukulhase/WebWhatsapp-Wrapper。我将此(https://www.raspberrypi.org/forums/viewtopic.php?t=167292#p1246095)用作安装Gecko Driver的“教程”。代替

curl -O {link}

我用过

wget {link}

因为

tar -xzvf {file} 

不是为我工作。

当我想打开Firefox时(您可以在下面的代码中看到),它失败了。我希望有人能帮助我。

我尝试使用其他版本的geckodriver,但它也无法正常工作。

>>> from selenium import webdriver
>>> browser = webdriver.Firefox()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: -11

2 个答案:

答案 0 :(得分:0)

有人发现RasPi Zero使用arm6hf,但是我使用geckodriver作为arm7hf。

答案 1 :(得分:0)

此错误消息...

selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: -11

...表示subprocess exited状态代码为:-11

您需要从Releases · mozilla/geckodriver下载最新的匹配的 geckodriver

在使用 Raspberry Pi Zero W 时,您需要下载 geckodriver-v0.23.0-arm7hf.tar.gz 并将其保存在系统中。另外,您需要提及 geckodriver 二进制文件的绝对路径,并通过 argument executable_path 如下:

from selenium import webdriver

driver = webdriver.Firefox(executable_path='/path/to/geckodriver')
driver.get("http://google.com/")
driver.quit()

参考

相关问题