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