前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=...)

unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=...)

作者头像
周小董
发布2019-03-25 11:18:59
2.9K0
发布2019-03-25 11:18:59
举报
文章被收录于专栏:python前行者python前行者

linux下命令行运行报错

Message: unknown error: Chrome failed to start: exited abnormally

(Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.14.0-deepin2-amd64 x86_64)

找到一种解决方案(这种方法对我不起作用,往下看)https://blog.csdn.net/xuwukui/article/details/79042994

先执行一下两句安装命令(以ubuntu为例):

代码语言:javascript
复制
pip install pyvirtualdisplay
sudo apt-get install xvfb

然后添加如下代码:

代码语言:javascript
复制
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 800))  
display.start()
driver = webdriver.Chrome()

google到另外一种解决方案,完美解决https://groups.google.com/forum/#!topic/qaf-users/ZRUbGWSL7Y8

代码语言:javascript
复制
You are using arg --headless so with that my be you can try with another argument --no-sandbox and window-size=1024,768.

chrome.additional.capabilities={"chromeOptions":{"args":["--headless", "window-size=1024,768", "--no-sandbox"], "binary": "/home/ubuntu/software/chromedriver"}}

You can refer following

https://stackoverflow.com/questions/22558077/unknown-error-chrome-failed-to-start-exited-abnormally-driver-info-chromedri
https://github.com/SeleniumHQ/selenium/issues/4961

按照上面给出的解决方案把代码修改如下:

代码语言:javascript
复制
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument("window-size=1024,768")
#添加沙盒模式
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(chrome_options=chrome_options)

参考:https://blog.csdn.net/daocaoren92wq/article/details/80155595

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年09月05日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档