首页 > 技术文章 > WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

maybach 2021-04-29 22:02 原文

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

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

这是因为缺少 chromedriver依赖

环境: ubuntu20.04 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

 

 

安装依赖:

sudo apt-get install libgconf-2-4

 

问题解决!

 

 

推荐阅读