Mac “'chromedriver' executable needs to be in PATH”

安装selenium

pip install selenium

Mac 下使用selenium打开一个空的浏览器窗口:

from selenium import webdriver
driver = webdriver.Chrome()

报错:

'chromedriver' executable needs to be in PATH

解决

方法一:直接下载chromedriver并添加路径

1.下载chromedriver,查看chrome浏览器版本为62
下载地址:http://npm.taobao.org/mirrors/chromedriver/2.33/

Mac “'chromedriver' executable needs to be in PATH”_第1张图片

下载成功,无需安装

2.添加chromedriver路径,再次运行:

from selenium import webdriver
driver = webdriver.Chrome('/Users/username/Downloads/chromedriver')

打开网页成功,问题解决!


方法二:使用brew安装chromedriver

1.brew安装chromedriver

$ brew install chromedriver

2.安装完成后,再次运行:

from selenium import webdriver
driver = webdriver.Chrome()

打开网页成功,问题解决!


附图:

Mac “'chromedriver' executable needs to be in PATH”_第2张图片


可参考:

  • https://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path

你可能感兴趣的:(答疑解惑)