Selenium gives "selenium.common.exceptions.WebDriverException: Message: Unknown error: Cannot find Chrome binary" on Mac

Trying to get selenium to work with Python 3 for web cleaning:

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

The following error message appears:

selenium.common.exceptions.WebDriverException: Message: Unknown error: Cannot find Chrome binary

A similar question has been addressed here , but what worries me is that Chrome is already installed on my system. Apparently, another adek did not have this on his computer. I am using the latest version of Mac OS.

+5
source share
6 answers

The problem is that the chromedriver also needs to know where the chrome is. In your case, this is not the default path. Therefore, you need to specify the full path to the Google Chrome binary.

 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) 

Above code is what you should use

+12
source

If your chromedriver is located in the /Library/Frameworks/Python.framework/Versions/3.6/bin/ directory, the following code block should work for you:

 from selenium import webdriver chrome_path = r'/Library/Frameworks/Python.framework/Versions/3.6/bin/chromedriver' driver = webdriver.Chrome(executable_path=chrome_path) driver.get('https://www.google.co.in') 
+1
source
 options = webdriver.ChromeOptions() options.binary_location = r"<YOUR_CHROME_PATH>\chrome.exe" chrome_driver_path = r"<PATH_TO_CHROME_DRIVER>\chromedriver.exe>" browser = webdriver.Chrome(chrome_driver_path, chrome_options=options) 
+1
source

I ran into this annoying problem when I learn selenium. This is my solution: (MacOS 10.13.4)

  1. remove my chrome
  2. use homebrew to install chromedriver: brew cask install chromedriver
  3. use homebrew to install chrome: brew cask install google-chrome

Thanks to homebrew, chrome and chromedriver are now installed in the same folder, and this problem will be automatically solved.

+1
source

If someone gets the same error on a Linux computer, then you are missing the installation of Google Chrome, as this is one of the steps necessary for the Chrome driver to work.

Follow the link below to install Google Chrome on Linux,

https://www.cyberciti.biz/faq/howto-install-google-chrome-on-redhat-rhel-fedora-centos-linux/

Now check the code

driver = webdriver.Chrome (executetable_path = '/ usr / bin / chromedriver', options = chrome_options, service_args = ['--verbose', '--log-path = / tmp / chromedriver.log'])

It worked for me.

0
source

On Win, it is important to set the name chrome.exe, otherwise it will not be able to create the process (see below):

  from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager options = webdriver.ChromeOptions() options.binary_location = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" chrome_driver_binary = r"C:/Users/Max/.wdm/chromedriver/75.0.3770.8/win32/chromedriver.exe" driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options) driver.get('http://web.whatsapp.com') 

selenium.common.exceptions.WebDriverException: Message: Unknown error: Could not create Chrome process.

For Firefox (download driver https://github.com/mozilla/geckodriver/releases ):

  options = webdriver.FirefoxOptions() #options.add_argument('-headless') #options.binary_location = r"C:\maxbook\maxboxpython\geckodriver-v0.24.0-win64\geckodriver.exe" options.binary_location = r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" firefox_driver_binary = r"C:\maxbook\maxboxpython\geckodriver-v0.24.0-win64\\" driver = webdriver.Firefox(firefox_driver_binary, options=options) 
0
source

Source: https://habr.com/ru/post/1273786/


All Articles