解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary_第1张图片出现selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary的报错:
问题原因:
一般是因为chrome.exe或者是chromedriver.exe有问题
解决方法
添加chrome.exe还有chromedriver.exe的绝对路径

解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary_第2张图片

from selenium import webdriver
option = webdriver.ChromeOptions()
option.binary_location = r'D:\Google chrome\Google\Chrome\Application\chrome.exe'
driver = webdriver.Chrome(r'D:\Google chrome\Google\Chrome\Application\chromedriver.exe')
driver.get("http://www.baidu.com")

重新运行下代码,问题解决,Google浏览器自动打开了
解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary_第3张图片

你可能感兴趣的:(解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary)