WebDriverException:消息:未知错误:Chrome无法启动:通过ChromeDriver在VPS上通过Python与ChromeDriver Chrome和Selenium异常退出 [英] WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS

查看:220
本文介绍了WebDriverException:消息:未知错误:Chrome无法启动:通过ChromeDriver在VPS上通过Python与ChromeDriver Chrome和Selenium异常退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我和这些帖子有完全相同的错误

So I have the exact same error as these posts

硒"Chrome无法启动:异常退出"错误

未知错误:Chrome无法启动:异常退出

我尝试了他们的建议,但没有成功.

I tried what they recommended and it didn't work.

这是我的代码

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()

这是完整的错误消息

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)

我到底在做什么恶魔?我在digitalocean的ubuntu VPS上运行它.

What the devil am I doing wrong? I'm running this on an ubuntu VPS on digitalocean.

推荐答案

此错误消息...

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)

...表示 ChromeDriver 无法启动/产生新的 WebBrowser ,即 Chrome浏览器会话.

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

正好有两个不兼容问题,如下所述.

There are exactly two incompatibility issues as discussed below.

Google团队 Headless Chrome 作为 GA(通用)首次发布时,文章

When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome mentioned that :

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

注释添加为:

现在,如果您在Windows上运行,则还希望包含--disable-gpu标志.

根据讨论无头:make --disable-gpu标志很明显:

Linux Mac OSX 上不再需要--disable-gpu标志.一旦错误 SwiftShader断言失败,Windows上也将不再需要它.在Windows中以无头模式已修复.现在,此问题已标记为已修复,参数--disable-gpu现在应该已经多余.

The --disable-gpu flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed. Now as this issue is marked fixed the argument --disable-gpu should be redundant now.

注意:您可以在但是,您的主要问题是正在使用的二进制文件版本之间的不兼容性:

However, your main issue is the incompatibility between the version of the binaries you are using as follows:

支持 Chrome v58-60

  • 您不知道您的 chrome 版本.假设您使用的是以下最新版本的 Chrome :
    • Chrome version 71
    • Chrome version 72
    • Chrome version 73
      • Your chrome version is unknown to us. Assuming you are using on of the latest Chrome releases either among:
        • Chrome version 71
        • Chrome version 72
        • Chrome version 73
        • 因此 ChromeDriver v2.30 Chrome浏览器v71-73

          • 根据您的 Chrome浏览器版本升级 ChromeDriver ,相应地遵循此讨论针对支持它的 ChromeDriver 版本.
查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆