selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PAT

原文链接:https://blog.csdn.net/Wangm857/article/details/102747352

在使用selenium模块操作浏览器时,出现下面的错误提示:selenium.common.exceptions.WebDriverException:
Message: ‘chromedriver’ executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home

这是系统没找到浏览器的驱动driver导致的,在网上看了一些大神的解决方法,总结了一个比较简单的方法:

1.首先要下载驱动,我的系统windows系统,使用的是谷歌Chrome浏览器,所以下载chromedriver:

1) 打开Chrome浏览器输入“chrome://version/”,查看所用浏览器的版本如下图:**

2)下载chromedriver.exe, 有两个比较常用的网址:**
[下载地址1:] http://chromedriver.storage.googleapis.com/index.html
[下载地址2: ] http://npm.taobao.org/mirrors/chromedriver/

选择与浏览器对应的版本,下面的三个都可以

 

notes.txt :版本适用说明
win32.zip: windows 64位和32位都可以通用

2. 解压下载好的文件,并将解压好的chromedriver.exe文件复制到Python的安装目录下面,
要注意的是:Python的安装目录在设置系统环境变量时是添加过的。
比如我的python安装目录是:D:\python
(如果将chromedriver.exe放在其他的目录下面,也必须将这个目录添加到系统环境变量值里)

3.如果设置了系统环境变量需要重启计算机才可以
4.运行下面的代码就能看到系统自动打开Chrome浏览器了:

from selenium import webdriver

url = "https://wwww.baidu.com"
browser = webdriver.Chrome()
browser.get(url)

  

原文地址:https://www.cnblogs.com/qqq789001/p/15734429.html