一、概述
使用自动化 selenium 时报出 Message: ‘chromedriver’ executable needs to be in PATH 错误。
二、解决方法
2.1 查看 chrome 版本号
打开 chrome 浏览器,在地址栏输入:chrome://version/
获取版本信息。
2.2 下载对应版本的 chromedriver.exe
打开 chromedriver,下载 chromedriver.exe
2.3 将 chromedriver.exe 复制到 Chrome 和 Python 根目录下
我的电脑为:
- C:\Program Files (x86)\Google\Chrome\Application
- E:\python3
大家以自己的电脑的目录为准。
2.4 添加 Application 目录到环境变量 path 中
将刚才的 C:\Program Files (x86)\Google\Chrome\Application 添加到 path 中。