Solving Selenium Error – Message: unknown error: cannot find Chrome binary on Mac

Message: unknown error: cannot find Chrome binary on Mac is an error which happens in Python and Selenium when chromedriver does not know where chrome is located.

In this article I am going to explain why the error is occurring and how to solve it using multiple solutions which may work for your particular case.

Exploring the Error Message: unknown error: cannot find Chrome binary on Mac

The error happens in Python and Selenium when chromedriver does not know where chrome is located.

A simple code like this can cause the error, pay attention to chrome_path = …

                                                                       #
from selenium import webdriver
chrome_path = r"/Library/Frameworks/Python.framework/Versions/3.6/bin/chromedriver"
driver = webdriver.Chrome(chrome_path)
                                                                       #

The error message should be the exact as this one or at least very similar in order to avoid all types of confusion.

                                                                       #
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
                                                                       #

Bellow I present multiple solutions that might solve the problem for you.

Solution 1 : use homebrew

The easiest solution is to use homebrew, homebrew will automatically install chromedriver and chrome in the same folder. Thus you do not need to do anything else because the problem will be gone automatically.

So, first start by uninstalling chrome. Second thing you need to do is to install chromedriver using homebrew.

                                                                       #
brew cask install chromedriver
                                                                       #

Third thing you need to do is to install chrome using homebrew.

                                                                       #
brew cask install google-chrome
                                                                       #

The problem should be solved by now, try the fix bellow if that is far from the truth.

Solution 2 : specify the Absolut path to the Google Chrome binary

The second solution is to always specify the Absolut path to the Google Chrome binary. This is going to allow chromedriver to know where chrome is located.

Try the code bellow and the error should be gone.

                                                                       #
options = webdriver.ChromeOptions()
options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
chrome_driver_binary = "/usr/local/bin/chromedriver"
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
                                                                       #

If the solutions above helped you, consider supporting us on Kofi, any help is appreciated.

Summing-up

Thank you guys for reading, I hope this article helped you solve the issue at hand, I hope the error is gone after following one of the solutions I described above.

Keep coding, errors are normal, keep learning, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/