WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome
Solution 1
This error message...
WebDriverException: unknown error: cannot find Chrome binary
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
As per the ChromeDriver - Requirements:
The server expects you to have Chrome installed in the default location for each system:
OS Expected 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 newer C:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe 1 For Linux systems, the ChromeDriver expects
/usr/bin/google-chrome
to be a symlink to the actual Chrome binary.
Using a Chrome executable in a non-standard location
However you can also override the default Chrome binary location as follows:
To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code:
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:
Solution 2
What happened to me is that I didn't have chrome, the main browser, installed. Download the browser and it fixes this issue.
Related videos on Youtube
Venetian
Updated on March 12, 2022Comments
-
Venetian about 2 years
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/.
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)
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!
-
Sasha almost 6 yearsTry use single forward slashes instead of double back slashes
-
Venetian almost 6 yearsThanks, but both single and double forward slashes return the same error above.
-
-
Venetian almost 6 yearsThat is for the path to the webdriver binary, no? I think what I need is how to correctly specify the chrome binary.
-
Venetian almost 6 yearsThis worked, thank you. For future reference, I put both the chrome and chromedriver executables in the same directory.
-
Nhân Nguyễn about 5 yearswhere can I download chrome binary for linux?
-
Raketenolli over 4 yearsWhat about Windows 10? It does not work with a link named "chrome.exe" in the path shown for Vista.
-
dtar over 4 yearsUpdate 2019: use options=options instead of chrome_options=options
-
gumuruh about 3 yearsi wish i could switch to my own cefsharp embed on panel iinstead of the chrome installed.
-
Peter Smith about 3 yearsI read another comment that said I might need to install Chrome itself, not just the wrapper from selenium called 'chromedriver' -- the .so on my Chromebook. so i finally managed to run the following command to install my Chrome executable, and then things worked. it's weird to think you have to (re?)install Chrome on a Chromebook, but the Linux VM didn't seem to be able to find it. maybe I just didn't know where to look.
> sudo dpkg -i google-chrome-stable_current_amd64.deb
-
Steve Smith over 2 yearsIt's probably a version thing, but on my system the setting is
options.BinaryLocation
. -
saadlulu over 2 yearsoh thank you, I have been using Brave browser, thinking "yeah this is chrome" but no it's not. downloading actual chrome fixed it. thanks
-
Ethan about 2 yearsWhile this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review