python - selenium.common.exceptions.WebDriverException : Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium

标签 python selenium google-chrome selenium-webdriver selenium-chromedriver

我正在尝试在 Linux 服务器上运行网络爬虫。完整错误如下

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally 
(Driver info: chromedriver=2.10.267518,platform=Linux 4.4.0-141-generic x86_64)

我在 stackoverflow 上看到过类似的问题,解决方案包括“--headless”和“--no-sandbox”参数。但是,我已经在这样做了。

我可以在本地运行这段代码,但是,我无法让它在服务器上运行。

我也检查过一切都是最新的,一切都是。

ChromeDriver 2.10.267518
selenium     3.141.0

这是发生错误的代码片段。

options.add_argument('--headless')
options.add_argument('--no-sandbox')

caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'performance': 'ALL'}

driver = webdriver.Chrome(options=options, desired_capabilities=caps, executable_path='/usr/local/bin/chromedriver')

我也尝试过在没有 executable_path 选项的情况下运行上面的代码,但我仍然遇到同样的错误。

最佳答案

我使用的配置文件将 header 值设置为 True,因此代码试图在浏览器中运行但失败了。这是一个愚蠢的错误,但无论如何我都会发布解决方案以防它对某人有所帮助。

我还必须删除下面的行

options.add_argument('--no-sandbox')

并改变这一行

options.add_argument('--headless')

options.add_argument('headless')

关于python - selenium.common.exceptions.WebDriverException : Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54561314/

相关文章:

python - python 中字符集之间的转换

javascript - 使用 selenium 抓取 Tripadvisor 时如何单击 "More"按钮?

html - 在 Chrome 中使用 CSS 中断控件的滚动条调整 HTML 选择的大小

python - 用 Nose 测试。为什么我收到 "ImportError: No module named bin.app"

python - 在发送之前修改url以在scrapy中获取

java - selenium webdriver java 下拉框

python - 如何从 URL 列表中获取属性 ('innerHTML' ) - Selenium?

Chrome 中的 Javascript 链接错误在所有其他浏览器中工作正常?

Javascript:获取浏览器选择的麦克风名称

Python 顶级二元组