加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

安装 chromedriver 依赖

发布时间:2020-12-14 04:31:11 所属栏目:百科 来源:网络整理
导读:背景 使用selenium驱动Chrome, 但是执行的时候报错, WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127 这是因为缺少 chromedriver依赖 环境: centos 7 64 操作 驱动Chrome程序 from selenium import webdri

背景

使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读