重装系统后:selenium无法找到chrome--selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
一、报错
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

翻译过来为:selenium.common.exceptions.WebDriverException:消息:未知错误:找不到Chrome二进制文件
即找不到chrome浏览器
二、解决方法
添加chrome路径:
ops.binary_location = r'I:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
ops是传递给option的对象
完整为:
from selenium.webdriver.chrome.options import Options
ops.binary_location = r'I:\Program Files (x86)\Google\Chrome\Application\chrome.exe'(此处是我的chrome位置,需要在r""中填上自己的chrome位置)
browser = webdriver.Chrome(options=ops)

这个是我自己设置的输出,出现代表着正确
三、第二个报错:
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chrome
连接错误,需要
ping localhost
如果为ping的结果为:
一般错误
一般错误
一般错误
这样的结果
则存在错误
四、解决方法:
关闭防火墙


再次,
ping localhost

参见《mac selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedri》链接: link.

本文详细介绍了在重装系统后,使用Selenium时遇到的Chrome浏览器无法启动的问题及解决方案。首先,需要确保Selenium能找到Chrome的安装路径,通过添加Chrome的二进制文件路径到Selenium配置中可以解决这一问题。其次,文章还讨论了当Selenium无法连接到Chrome服务时的解决办法,通常关闭防火墙能有效解决此类连接问题。

被折叠的 条评论
为什么被折叠?



