Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome

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!

like image 792
Venetian Avatar asked May 02 '18 15:05

Venetian


People also ask

How to resolve unknown Error cannot find Chrome binary?

I have solved this problem by installing Google Chrome link and it solved problem automatically (I use Kali Linux) and be sure that it is installed to the "/usr/bin"(default it is downloaded to here).

Where is my chrome binary located?

q2. What is the exact path to the chrome binary on your PC? If you are working on Windows 10, it would be C:\Program Files (x86)\Google\Chrome\Application\chrome.exe .

How do I change the binary path in Chrome?

ChromeOptions optionsBeta = new ChromeOptions(); optionsBeta. setBinary(“path\\to\\chrome\\browser\\beta\\binary”); WebDriver driver = new ChromeDriver(optionsBeta);


3 Answers

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

Related Docs


Reference

You can find a detailed discussion in:

  • Is Chrome installation needed or only chromedriver when using Selenium?
like image 179
undetected Selenium Avatar answered Oct 13 '22 05:10

undetected Selenium


What happened to me is that I didn't have chrome, the main browser, installed. Download the browser and it fixes this issue.

like image 29
ossendryver Avatar answered Oct 13 '22 07:10

ossendryver


Using an old version of chrome driver with the latest Google Chrome locally gave me the same exception.

Just go to the ChromeDriver page and make sure you have the latest version.

like image 1
meJustAndrew Avatar answered Oct 13 '22 05:10

meJustAndrew