在调用selenium的Chrome过程中遇到如下错误,在网上找了很多方法都没有解决,最终发现是谷歌Chrome与Chromedriver的版本问题。

成功解决成功解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome bi

解决该问题用了比较粗暴的方法,将selenium、Chrome和Chromedriver都重新下载了

一、卸载和下载selenium

二、下载谷歌Chrome浏览器

三、下载Chromedriver

四、配置环境变量

一、卸载和下载selenium

只需在cmd输入:

pip uninstall selenium
pip install selenium

二、下载谷歌Chrome浏览器

百度上搜索下载即可

三、下载Chromedriver

1、首先查看自己的Chrome版本,点击设置,关于Chrome即可。

成功解决成功解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome bi

2、下载Chromedriver,链接:https://chromedriver.storage.googleapis.com/index.html,选择对应的版本,我这里是104.0.5112.81,选下面其中一个根据自己的电脑系统下载都行。

成功解决成功解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome bi

四、配置环境变量

将下载的Chromedriver文件放在你的python路径下,这里我的路径是“C:\Users\HP\AppData\Local\Programs\Python\Python310”

接下来在控制面板找到系统属性,找到环境变量

成功解决成功解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome bi成功解决成功解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome bi

 进入新建,将刚刚的路径复制进去即可。

 再重新运行代码:

from selenium import webdriver
driver = webdriver.Chrome()
url = 'http://www.baidu.com'
driver.get(url)

 正常运行。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。