WebDriverException:消息:服务chromedriver意外退出.状态码为:127 [英] WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

查看:961
本文介绍了WebDriverException:消息:服务chromedriver意外退出.状态码为:127的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在服务器上使用硒构建爬虫.

I'd like to construct my crawler using selenium on my server.

因此,我已经在Ubuntu17.10服务器上安装/下载了所需的依赖项,例如chromedriver,chrome-browser等

Thus I had installed/download required dependencies- such as chromedriver, chromium-browser etc on my Ubuntu17.10 server

但是,当我运行以下代码时:

However, when I run following code:

driver = webdriver.Chrome()

它返回以下错误:

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-14-2cdab8938403> in <module>()
----> 1 driver = webdriver.Chrome()

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options)
     66             service_args=service_args,
     67             log_path=service_log_path)
---> 68         self.service.start()
     69 
     70         try:

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self)
     96         count = 0
     97         while True:
---> 98             self.assert_process_still_running()
     99             if self.is_connectable():
    100                 break

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
    109             raise WebDriverException(
    110                 'Service %s unexpectedly exited. Status code was: %s'
--> 111                 % (self.path, return_code)
    112             )
    113 

WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

这是什么意思呢?

我无法获得该错误代码的初衷以及从何处修复该错误代码.

I can't get what the original intention of that error code and where to start to fix it.

这种情况很少见.

可能相关:

我已经在台式机上安装了ubuntu台式机17.10,但是无法启动GUI.因此,我仅使用终端,但到目前为止效果很好. 我已经从Mac到服务器桌面安装了ssh和远程控制jupyter笔记本,而这些错误是由它引起的. 希望此信息与解决此错误有关,否则将中止该信息.

I had install ubuntu desktop 17.10 on my desktop but failed to get GUI boot. Thus I am just using terminal only, but it well works so far. I had installed ssh and remote controlling jupyter notebook from my mac to server desktop, and those errors comes from it. Hope this info is relevant to solve this error, otherwise will abort it.

推荐答案

似乎chromedriver需要一些额外的库.这为我解决了这个问题:

It seems chromedriver needs some extra libraries. This solved the issue for me:

apt-get install -y libglib2.0-0=2.50.3-2 \
    libnss3=2:3.26.2-1.1+deb9u1 \
    libgconf-2-4=3.2.6-4+b1 \
    libfontconfig1=2.11.0-6.7+b1

我正在使用docker容器而不是没有X/GUI的服务器/VM进行类似的设置.

I was working on a similar setup using a docker container instead of a server/VM without X / GUI.

要弄清需要哪些依赖关系,我反复尝试从命令行运行它,如下所示:/opt/chromedriver/2.33/chromedriver --version一遍又一遍.

To figure out which dependencies are required I tried iteratively to run it from the command line like this: /opt/chromedriver/2.33/chromedriver --version over and over again.

然后每次我都使用诸如apt-cache search <STUFF>apt-cache madison <STUFF>之类的命令来找出chromedriver 2.33所需的deb软件包的确切版本(在我的情况下,但我想类似的东西对于任何chromedriver的版本.

Then at eache time I used commands like apt-cache search <STUFF> and apt-cache madison <STUFF> to figure out the exact version of the deb package needed by chromedriver 2.33 (in my case, but I guess something similar would work for any version of chromedriver).

这篇关于WebDriverException:消息:服务chromedriver意外退出.状态码为:127的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆