[英]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.如下所述,正好有两个不兼容问题。
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 .在Linux或Mac 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:但是,您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:
Supports Chrome v58-60
支持Chrome v58-60
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.30和Chrome 浏览器 v71-73之间存在明显的不匹配
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.