我正在尝试在Ubuntu 16.10 Server上运行Selenium,但是却遇到了WebDriverException:消息:无法访问chrome(驱动程序信息:chromedriver 2.9.248304,平台= Linux 4.8.0-22-通用x86_64)
from pyvirtualdisplay import Display from selenium import webdriver display = Display(visible=0, size=(800, 600)) display.start() browser = webdriver.Chrome('usr/bin/chromedriver') browser.get('http://www.google.com') print(browser.title) browser.quit() display.stop()
Chrome已安装:
google-chrome --version
谷歌浏览器57.0.2987.110
添加一些镀铬选项有帮助!
chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--no-sandbox') chrome = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=chrome_options)