WebDriverException:未知错误:对于较旧版本的Google Chrome,无法在Python中使用Selenium找到Chrome二进制错误 [英] WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome
问题描述
出于兼容性原因,我更喜欢将Chrome版本55.0.2883.75与Chromedriver v.2.26一起使用.我从 https://www.slimjet.com下载了旧版的chrome./chrome/google-chrome-old-version.php 和
For compatibility reasons I prefer to use Chrome version 55.0.2883.75 with Chromedriver v. 2.26. I downloaded the older version of chrome from https://www.slimjet.com/chrome/google-chrome-old-version.php and Chromedriver 2.26 from https://chromedriver.storage.googleapis.com/index.html?path=2.26/.
我正在使用以下代码尝试设置我的Chrome二进制位置:
I am using the following code to attempt to set my Chrome binary location:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)
但是,当我尝试启动WebDriver Python时,返回以下错误:
However, when I attempt to launch the WebDriver Python returns the following error:
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
我尝试搜索类似的问题和答案,但到目前为止还没有任何运气.非常感谢您的帮助-预先感谢您!
I have tried searching through similar questions and answers but have not had any luck so far. Any help is greatly appreciated - thank you in advance!
推荐答案
此错误消息...
WebDriverException: unknown error: cannot find Chrome binary
...表示 ChromeDriver 无法在系统默认位置找到 Chrome 二进制文件.
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
ChromeDriver 服务器希望您将Chrome安装在每个系统的默认位置,如下所示:
The ChromeDriver server expects you to have Chrome installed in the default location for each system as follows:
1 对于Linux系统, ChromeDriver 期望/usr/bin/google-chrome
是与实际 Chrome二进制文件的符号链接 >.
1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome
to be a symlink to the actual Chrome binary.
但是,您也可以按如下方式覆盖默认的 Chrome二进制位置:
However you can also override the default Chrome binary location as follows:
要使用通过 ChromeDriver v2.26 安装在非标准位置的 Chrome版本55.x ,可以使用以下代码块:
To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code block :
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
参考
您可以在以下位置找到详细的讨论:
Reference
You can find a detailed discussion in:
这篇关于WebDriverException:未知错误:对于较旧版本的Google Chrome,无法在Python中使用Selenium找到Chrome二进制错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!