简体   繁体   English

WebDriverException:消息:未知错误:Chrome 无法启动:通过 VPS 上的 Python 使用 ChromeDriver Chrome 和 Selenium 异常退出

[英]WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS

So I have the exact same error as these posts所以我有与这些帖子完全相同的错误

Selenium 'Chrome failed to start: exited abnormally' error Selenium 'Chrome 启动失败:异常退出'错误

Unknown error: Chrome failed to start: exited abnormally 未知错误:Chrome 无法启动:异常退出

I tried what they recommended and it didn't work.我尝试了他们推荐的方法,但没有奏效。

Here is my code这是我的代码

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-extensions')
options.add_argument('--headless')
options.add_argument('--disable-gpu')

driver = webdriver.Chrome(chrome_options=options)
driver.get('http://nytimes.com')
print(driver.title)

driver.close()

And here is the full error message这是完整的错误消息

Traceback (most recent call last):
  File "seleniumtest.py", line 13, in <module>
    driver = webdriver.Chrome(chrome_options=options)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.15.0-42-generic x86_64)

What the devil am I doing wrong?我到底做错了什么? I'm running this on an ubuntu VPS on digitalocean.我在 digitalocean 上的 ubuntu VPS 上运行它。

This error message...这个错误信息...

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.15.0-42-generic x86_64)

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser ie Chrome Browser session. ...暗示ChromeDriver无法启动/生成新的WebBrowser,Chrome 浏览器会话。

There are exactly two incompatibility issues as discussed below.如下所述,正好有两个不兼容问题。


disable-gpu禁用-gpu

When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome mentioned that :Google 团队首次将Headless Chrome作为GA(通用可用性)发布时,文章Getting Started with Headless Chrome提到:

--disable-gpu \                # Temporarily needed if running on Windows.

A note was added as :添加了一个注释:

Right now, you'll also want to include the --disable-gpu flag if you're running on Windows.现在,如果您在 Windows 上运行,您还需要包含--disable-gpu标志。

As per the discussion Headless: make --disable-gpu flag unnecessary it was clear that :根据讨论Headless: make --disable-gpu flag 不必要,很明显:

The --disable-gpu flag is no longer necessary on Linux or Mac OSX .LinuxMac OSX上不再需要--disable-gpu标志。 It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed.一旦错误SwiftShader 在无头模式下的 Windows 上断言修复,它也将在 Windows 上变得不必要。 Now as this issue is marked fixed the argument --disable-gpu should be redundant now.现在,由于此问题已标记为已修复,因此参数--disable-gpu现在应该是多余的。

Note : You can find a detailed discussion in ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode注意:您可以在ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context 中找到详细讨论:在 Headless 模式下通过 ChromeDriver 初始化 Chrome 浏览器时


However, your main issue is the incompatibility between the version of the binaries you are using as follows:但是,您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:

  • You are using chromedriver=2.30您正在使用chromedriver=2.30
  • Release Notes of chromedriver=2.30 clearly mentions the following : chromedriver=2.30 的发行说明清楚地提到了以下内容:

Supports Chrome v58-60支持Chrome v58-60

  • Your chrome version is unknown to us.我们不知道您的chrome版本。 Assuming you are using on of the latest Chrome releases either among:假设您使用的是以下任一版本的最新Chrome版本:
    • Chrome version 71
    • Chrome version 72
    • Chrome version 73

So there is a clear mismatch between ChromeDriver v2.30 and the Chrome Browser v71-73所以ChromeDriver v2.30Chrome 浏览器 v71-73之间存在明显的不匹配

Solution解决方案

  • Depending on your Chrome Browser version upgrade ChromeDriver accordingly following the guidelines below:根据您的Chrome 浏览器版本,按照以下 指南相应地升级ChromeDriver
    • If you are using Chrome version 73 , you need to download ChromeDriver 73.0.3683.20如果您使用的是Chrome 73 版,则需要下载ChromeDriver 73.0.3683.20
    • If you are using Chrome version 72 , you need to download ChromeDriver 2.46 or ChromeDriver 72.0.3626.69如果您使用的是Chrome 72 版,则需要下载ChromeDriver 2.46或 ChromeDriver 72.0.3626.69
    • If you are using Chrome version 71 , you need to download ChromeDriver 2.46 or ChromeDriver 71.0.3578.137如果您使用的是Chrome 71 版,则需要下载ChromeDriver 2.46或 ChromeDriver 71.0.3578.137
    • For older version of Chrome , see this discussion for the version of ChromeDriver that supports it.对于旧版本的Chrome ,请参阅此讨论了解支持它的ChromeDriver版本。

References参考

You can find a couple of relevant discussions in:您可以在以下位置找到一些相关讨论:

You haven't provided your browser's version, but chromedriver 2.30 is pretty old - circa June 2017;您尚未提供浏览器的版本,但 chromedriver 2.30 已经旧了 - 大约 2017 年 6 月; Chrome was version 59 then, and at 72 now. Chrome 当时是 59 版,现在是 72 版。 ( yes, I checked, it's not like I know their release history by heart 😀 ) 是的,我查过了,我不是很清楚他们的发布历史😀

I'd suggest to upgrade it to a recent version - or to one matching your installed browser.我建议将其升级到最新版本 - 或升级到与您安装的浏览器相匹配的版本。

暂无
暂无

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

相关问题 WebDriverException:消息:未知错误:Chrome 无法启动:通过 WebDriverManager 使用 Selenium ChromeDriver 和 Chrome 异常退出 - WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally using Selenium ChromeDriver and Chrome through WebDriverManager WebDriverException:消息:未知错误:Chrome 无法启动:使用 ChromeDriver Chrome 和 Selenium Python 异常退出错误 - WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally error using ChromeDriver Chrome and Selenium Python selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:使用ChromeDriver Chrome和Selenium异常退出 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium WebDriverException:消息:未知错误:Chrome 无法启动:在 debian 服务器上使用 ChromeDriver Chrome 和 Selenium 异常退出 - WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server 设置 selenium 与 headless chrome 错误:WebDriverException:消息:未知错误:Chrome 无法启动:异常退出 - Setup selenium with headless chrome error: WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally Python:Selenium-消息:未知错误:Chrome无法启动:异常退出 - Python : Selenium - Message: unknown error: Chrome failed to start: exited abnormally WebDriverException:消息:未知错误:Chrome 无法启动:在 Amazon Linux 上通过 Selenium Python 使用 ChromeDriver Chrome 出现崩溃错误 - WebDriverException: Message: unknown error: Chrome failed to start: crashed error using ChromeDriver Chrome through Selenium Python on Amazon Linux TDD-Django(部署)错误:selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:异常退出 - TDD-Django(deploy) Error : selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:异常退出。 Dockerize Flask 应用程序 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. Dockerize Flask Application selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM