安装 chromedriver 依赖

前端之家收集整理的这篇文章主要介绍了安装 chromedriver 依赖前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

背景

使用selenium驱动Chrome, 但是执行的时候报错,

WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

这是因为缺少 chromedriver依赖

环境: centos 7 64

操作

驱动Chrome程序

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.binary_location = './chrome'
driver = webdriver.Chrome(chrome_options=chrome_options,executable_path="./chromedriver")
driver.get("http://www.duo.com")

查看 chromedriver 需要的依赖:
执行

./chromedriver --version

显示

./chromedriver: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory

列出软件包libgconf-2.so.4提供的文件

yum provides */libgconf-2.so.4

安装

sudo yum install  GConf2

如果 yum provides */libgconf-2.so.4 报错,可先执行 yum install libgconf-2.so.4

其他方法

有时候会发现按照上面的方法进行操作的时候,会发现缺少的包还依赖其他缺少的包。
实际就是缺少大量的依赖,如果手动一个一个是很费劲。
解决方法是直接安装 google-chrome。上述依赖环境就会自动被装好。
具体安装方法puppeteer使用代理 https://blog.csdn.net/a1368783069/article/details/80647970 中的 chrome 安装

参考:
https://stackoverflow.com/questions/37624225/shared-libraries-libgconf-2-so-4-is-missing/37624391?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

原文链接:https://www.f2er.com/javaschema/282181.html

猜你在找的设计模式相关文章