"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Solve the \"Cannot Find Chrome Binary\" Error in Selenium Python for Older Google Chrome Versions?

How to Solve the \"Cannot Find Chrome Binary\" Error in Selenium Python for Older Google Chrome Versions?

Published on 2024-11-03
Browse:950

How to Solve the \

Cannot Find Chrome Binary Error with Selenium Python for Older Google Chrome Versions

When using Selenium in Python with older versions of Google Chrome, you may encounter the following error:

WebDriverException: unknown error: cannot find Chrome binary

This error indicates that the ChromeDriver cannot locate the Chrome binary in its default location.

To resolve this issue, you can explicitly set the Chrome binary location using the binary_location option in the WebDriver options. For example:

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)

Ensure that the specified path points to the correct Chrome binary location for your older Chrome version.

Alternatively, you can install the corresponding ChromeDriver version that is compatible with your Chrome version. The ChromeDriver requirements document provides the expected Chrome binary locations for different operating systems:

OSExpected Location of Chrome
Linux/usr/bin/google-chrome1
Mac/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Windows XP%HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
Windows Vista and newerC:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe

By following these steps, you can prevent the "cannot find Chrome binary" error and ensure successful execution of your WebDriver scripts with older Chrome versions.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3