所以我和这些帖子有完全相同的错误
Selenium 'Chrome failed to start: exited abnormally' error
Unknown error: Chrome failed to start: exited abnormally
我尝试了他们的建议,但没有成功。
这是我的代码
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上运行它。
答案 0 :(得分:0)
您尚未提供浏览器的版本,但chromedriver 2.30版本很旧-大约2017年6月; Chrome当时的版本是59,现在是72。 (yes, I checked, it's not like I know their release history by heart )
我建议将其升级到最新版本-或升级到与您安装的浏览器匹配的版本。
答案 1 :(得分:-1)
此错误消息...
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浏览器会话。
正好有两个不兼容问题,如下所述。
Google团队将 Headless Chrome 作为 GA(通用)首次发布时,文章Getting Started with Headless Chrome
提到:< / p>
--disable-gpu \ # Temporarily needed if running on Windows.
注释添加为:
现在,如果您在Windows上运行,则还希望包含
--disable-gpu
标志。
根据讨论Headless: make --disable-gpu flag unnecessary,很明显:
中找到详细的讨论在 Linux 或 Mac OSX 上,不再需要
--disable-gpu
标志。修复了错误SwiftShader fails an assert on Windows in headless mode后,Windows上也将不再需要它。现在,此问题已标记为已修复,因此参数--disable-gpu
现在应该是多余的。
但是,您的主要问题是正在使用的二进制文件版本之间的不兼容性:
支持 Chrome v58-60
Chrome version 71
Chrome version 72
Chrome version 73
因此 ChromeDriver v2.30 与 Chrome浏览器v71-73
之间显然存在不匹配