python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

 

#!/usr/bin/python3
from selenium import  webdriver

wg = webdriver.Chrome()

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

 

 

提示:

Traceback (most recent call last):

  File "D:/Tool/PycharmProjects/chapter11/seleniumExample.py", line 2, in <module>

    wg = webdriver.Chrome()

  File "D:\Tool\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__

    self.service.start()

  File "D:\Tool\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start

    os.path.basename(self.path), self.start_error_message)

 

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

 

根据错误提示:Message: 'chromedriver' executable needs to be in PATH我们可以找到原因所在:chromedriver需要放在python安装路径下。

 

两种查看谷歌版本的方式:

 

chrome://settings/help //这是第一种看到谷歌版本方式

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

 

 

查看各位自己的谷歌浏览器版本,我这版本是 78.0.3904.108(正式版本)

 

然后去找和版本对应的谷歌新的驱动

 

http://chromedriver.storage.googleapis.com/index.html

去这里面进行选择自我版本对应的进行下载

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

 

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

 

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

 

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

我们将驱动移动到python的安装目录里去,不清楚各位安哪的我就直接截个图算了:

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

然后重新运行一下代码,看看有没有问题。

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

如果各位不想看到这个Chrome显示被自动化脚本控制的话,可以去设置的

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

python创建Chrome浏览器驱动时提示:selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

在次运行就不会出现啦