解决selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

在使用pycharm运行项目时,提示如下所示错误:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

解决方法:

1.先查看自己浏览器的版本

 2.再去下载该版本对应的ChromeDriver驱动

下载地址:http://chromedriver.storage.googleapis.com/index.html

如果没有完全对应的版本,下载一个相近版本的驱动就可以了

3.下载后解压到python安装的路径下,并加上如下代码

from selenium import webdriver
chrome_drive = r"C:UsersAdministratorAppDataLocalProgramsPythonPython37chromedriver.exe"
self.dr = webdriver.Chrome(executable_path = chrome_drive)

这样再次运行就可以成功了

原文地址:https://www.cnblogs.com/yindada/p/11512897.html