查看详情

“selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary”报错的解决方案

python调用selenium进行数据采集时,需要调用Google Chrome进行数据抓取,但是,调试的时候报错了。
cannot find Chrome binary出错

报错”selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary“了,按这个意思,应该是无法调用Google Chrome浏览器的执行文件,解决办法如下:
1、确认当前的Google Chrome版本号与chromedriver版本号一致,如果不一致,到http://chromedriver.storage.googleapis.com/index.html下载与当前chrome浏览 器对应的驱动。
http://selenium-release.storage.googleapis.com/index.html selenium下载地址;
2、将chromedriver.exe文件放入python的scripts目录,并将该scripts目录添加到系统path变量中;
3、找到Google Chrome安装目录,一般在C:\Users\Administrator\AppData\Local\Google\Chrome\Application\Google Chrome.exe,将Google Chrome.exe复制一个出来,并重命名为chrome.exe,并将目录C:\Users\Administrator\AppData\Local\Google\Chrome\Application\添加到系统path变量中

以上三步,基本能解决问题,网上一些帖子说在py脚本文件中加入options.binary_location=r'C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe' 指定绝对路径,这样挺麻烦的,治标不治本,后期你每个py脚本都要指定路径。

注:selenium调用chrome时,是调用chrome.exe,而不是默认的Google Chrome.exe


原创内容,转载请注明出处:网站建设,APP开发,小程序开发请找江西居道科技有限公司,http://www.juguw.net

智能建站系统代理招商
所属分类:文章中心      Time:2021-08-08 01:01:17      人气:19975
关闭
13517086454