python 中 chrome binary 文件找不到 高效解决方法


selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)

先自述下背景,由于本人受够了某些软件的默认位置压迫,所以,软件一般都安装在系统盘之外。开始学习selenium,装chromedriver,和chrome浏览器。可是,经过发现,这谷歌浏览器不能选择安装路径,这种尿性出于google考虑安装权限的考虑,可我感觉很不爽。于是乎,强行把chrome.exe  解压为chrome.7z  然后再次解压成一个文件夹。连同文件夹放在D盘我专门放置软件的地方。然后写了以下代码:

from selenium import webdriver  
import time  
b=webdriver.Chrome()
b.get('http://www.baidu.com')  
time.sleep(5) 

然后运行  就 报了红字错误。然后百度解决问题 ,中间的曲折过程不在赘述,花费了我一个上午的时间,才解决,很兴奋。

解决方法:找到selenium源码  我的路径是:D:\Soft_ware\Py\Lib\site-packages\selenium\webdriver\chrome

找到options.py    把自己的chrome文件位置放在_binary_location变量中  ,问题成功解决。

附图一张:

猜你喜欢

转载自blog.csdn.net/weixin_42183288/article/details/81269923