重装系统后:selenium无法找到chrome--报错selenium.common.exceptions.WebDriverException: Message: unknown error: c

重装系统后: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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值