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

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

问题描述

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

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

因此我已经在我的 Ubuntu17.10 服务器上安装/下载了所需的依赖项 - 例如 chromedriver、chromium-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.

这种情况看起来非常罕见.

It looks very rare case.

也许相关:

我在桌面上安装了 ubuntu 桌面 17.10,但无法启动 GUI.因此我只使用终端,但到目前为止它运行良好.我已经从我的 mac 到服务器桌面安装了 ssh 和远程控制 jupyter notebook,这些错误来自它.希望此信息与解决此错误相关,否则将中止.

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天全站免登陆