Solve – cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome

Solve – cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome is an error which occurs in Python when chromeDriver can not find the Chrome binary in your system.

In this Blog post, I am going to show you why the error is happening and how you can solve it.

I am also going to share with you other possible solutions which have worked for other developers who had the same error.

Explaining the Error : cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome

The error usually occurs when chromeDriver can not find the Chrome binary in your system.

Before we get into the fix, you might be wondering how we can replicate the error. The error can happen with any python script using Selenium and chrome.

This is an example of the message displayed with the error.

                                                                       #
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
                                                                       #

Bellow is a number of tested solutions that I have tried and worked for me.

Solution 1 : Download and install Chrome

The first solution may or may not be the one to save you a lot of time.

Sometimes you have another browser other than chrome. And you do not have chrome installed on your device.

The solution is simple, just install the chrome browser on your device, this solves the error in many different scenarios.

So, go to the official site and Download and install chrome. If this does not work, please try the next solution.

Solution 2 : override the default Chrome binary location

The second solution is to override the default Chrome binary location. Bellow is an example of how to to do this for Chrome version 55.x

First, let us start with the imports

                                                                       #
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
                                                                       #

Then, we can add the main part of the code.

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

If this solution does not work, please try the final solution, you never know, this might be it.

Solution 3 : install chromedriver

Sometimes, you think you have chromedriver installed and you are wasting your time trying to troubleshoot this error while you did not even install chromedriver.

Mac users, can use the command bellow, the methodology works also for the other operating systems.

                                                                       #
npm i chromedriver
                                                                       #

The error above was hard to deal with, I spent hours looking for a proper solution or set of solutions.

Summing-up

Here we are at the end of the road, at the end of this article, if you solved this error congrats, this was a confusing error for me the first time I encountered it.

Make sure to keep coding and keep learning, Python is my favourite programming language, it just needs some patience, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/