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

12

47

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.

Bechtel answered 2/5, 2018 at 15:45 Comment(2)
Try use single forward slashes instead of double back slashesPiecemeal
Thanks, but both single and double forward slashes return the same error above.Bechtel
S
89

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:

Stambul answered 2/5, 2018 at 17:39 Comment(7)
This worked, thank you. For future reference, I put both the chrome and chromedriver executables in the same directory.Bechtel
where can I download chrome binary for linux?Chanukah
What about Windows 10? It does not work with a link named "chrome.exe" in the path shown for Vista.Truax
Update 2019: use options=options instead of chrome_options=optionsCaviar
I 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.debOutpatient
It's probably a version thing, but on my system the setting is options.BinaryLocation.Penstock
google-chrome-stable --version Google Chrome 121.0.6167.139 chromedriver --version ChromeDriver 121.0.6167.139 pip show selenium Name: selenium Version: 4.17.2 but still the error..Pacheco
H
4

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

Hagiographa answered 11/1, 2021 at 10:14 Comment(2)
i wish i could switch to my own cefsharp embed on panel iinstead of the chrome installed.Infamy
oh thank you, I have been using Brave browser, thinking "yeah this is chrome" but no it's not. downloading actual chrome fixed it. thanksMeingolda
U
3

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.

Ulaulah answered 24/10, 2021 at 11:36 Comment(0)
P
3

On Mac, there is a new bug causing the same error even if Chrome is installed at the default place. This is because the new chromedriver is looking for "Google Chrome for Testing.app" instead.

I did the following:

mkdir foo
cd foo
npx @puppeteer/browsers install chrome@stable
mv chrome/mac-115.0.5790.102/chrome-mac-x64/Google\ Chrome\ for\ Testing.app /Applications
rm -rf chrome

Update: The latest version seems to be fixed now.

Penalize answered 31/7, 2023 at 5:34 Comment(0)
C
1

I faced similar issue in MacOS. Even after setting binary path in chromeoptions, it didn't work. It got fixed after installing npm i chromedriver

Cynthy answered 7/9, 2020 at 12:40 Comment(0)
L
1

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

Lionize answered 11/3, 2022 at 20:24 Comment(1)
While 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 ReviewPoetess
V
1

It is also important to download Chrome from the actual website. I ran into the same problem, but I had downloaded Chrome from the Ubuntu software package manager. I uninstalled the package manager version and installed from the website, and the error resolved. Same issue could probably arise installing from other package managers.

Volcanic answered 20/2, 2023 at 17:16 Comment(0)
R
1

I faced this error because i installed Chrome with flatpak then Selenium doesn't find the directory of the Driver. Then i installed Chrome with Fedora Store and fixed.

Raynata answered 25/4, 2023 at 22:55 Comment(0)
B
0

I did this to solve my problem

private WebDriver driver;

@Before
public void StartBrowser() {

System.setProperty("webdriver.chrome.driver", "C://opt//WebDriver//bin//chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.saucedemo.com/");}
Barny answered 14/12, 2021 at 21:48 Comment(0)
K
0

I think this is the easiest way;
Download chromedriver and chrome version [except 115.0.5790.110 (it does not work properly)] from this link : chrome-for-testing.

  1. Put the chrome driver in the chrome path
  2. Replace the below path with your Chrome version path
from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = "C:/Program Files/Google/Chrome Dev/Application/chrome.exe"
driver = webdriver.Chrome(options=options)
#################
driver.get('https://realpython.com/openpyxl-excel-spreadsheets-python/')
Kelter answered 29/7, 2023 at 8:7 Comment(0)
L
0

I faced this same issue when I was trying to use chrome driver win64 instead of win32(in my case)

Licentiate answered 15/10, 2023 at 4:24 Comment(0)
B
-1

Check https://sites.google.com/a/chromium.org/chromedriver/getting-started You can specify the binary path in the constructor of the webdriver:

driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.
Braise answered 2/5, 2018 at 15:49 Comment(1)
That is for the path to the webdriver binary, no? I think what I need is how to correctly specify the chrome binary.Bechtel

© 2022 - 2024 — McMap. All rights reserved.