WebDriverException:未知错误:在Python中找不到旧版本Google Chrome的带有Selenium的Chrome二进制错误

WebDriverException:未知错误:在Python中找不到旧版本Google Chrome的带有Selenium的Chrome二进制错误,python,selenium,google-chrome,selenium-webdriver,selenium-chromedriver,Python,Selenium,Google Chrome,Selenium Webdriver,Selenium Chromedriver,出于兼容性原因,我更倾向于使用Chromedriver v的Chrome版本55.0.2883.75。2.26. 我从下载了chrome和Chromedriver 2.26的旧版本 我正在使用以下代码尝试设置我的Chrome二进制位置: from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.binary_location =

出于兼容性原因,我更倾向于使用Chromedriver v的Chrome版本55.0.2883.75。2.26. 我从下载了chrome和Chromedriver 2.26的旧版本

我正在使用以下代码尝试设置我的Chrome二进制位置:

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返回以下错误:

WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
我尝试过搜索类似的问题和答案,但迄今为止没有任何运气。非常感谢您的帮助-提前谢谢

检查 您可以在webdriver的构造函数中指定二进制路径:

driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.
此错误消息

WebDriverException: unknown error: cannot find Chrome binary
…表示ChromeDriver无法在系统的默认位置找到Chrome二进制文件

根据:

ChromeDriver服务器希望您在每个系统的默认位置安装Chrome,如下所示:

1对于Linux系统,ChromeDriver希望
/usr/bin/google chrome
成为实际chrome二进制文件的符号链接


在非标准位置使用Chrome可执行文件 但是,您也可以覆盖默认的Chrome二进制位置,如下所示:


要使用通过ChromeDriver v2.26安装在非标准位置的Chrome版本55.x,您可以使用以下代码块:

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()

参考文献 有关详细讨论,请参见:


我在MacOS中遇到了类似的问题。即使在chromeoptions中设置了二进制路径,它也不起作用。在安装了npm i chromedriver之后,它得到了修复。发生在我身上的事情是,我没有安装chrome主浏览器。
下载浏览器并修复此问题。

尝试使用单正斜杠而不是双反斜杠,但单正斜杠和双正斜杠都返回上述相同错误。这是指向webdriver二进制文件的路径,否?我想我需要的是如何正确指定chrome二进制文件。这很有效,谢谢。作为将来的参考,我将chrome和chromedriver可执行文件放在同一个目录中。我在哪里可以下载适用于linux的chrome二进制文件?Windows 10呢?它不适用于Vista路径中名为“chrome.exe”的链接。2019年更新:使用options=options而不是chrome\u options=options我读到另一条评论说我可能需要安装chrome本身,而不仅仅是selenium的名为“chromedriver”的包装器——在我的Chromebook上也是如此。因此,我最终设法运行以下命令来安装我的Chrome可执行文件,然后一切正常。想到你必须(重新?)在Chromebook上安装Chrome是很奇怪的,但是Linux虚拟机似乎无法找到它。也许我只是不知道去哪里找<代码>>sudo dpkg-i google-chrome-stable\u current\u amd64.deb我希望我可以切换到我自己的cefsharp嵌入式面板,而不是安装的chrome。