OSError: [Errno 8] Exec format error selenium

Question:

Trying to learn how to use selenium, I managed to overcome first error which involved chrome driver not being in the path name but it has thrown up another error.

  from selenium import webdriver
    from selenium.webdriver.common.keys import Keys


    driver = webdriver.Chrome('/Users/williamneal/Scratch/Titanic/chromedriver')
    driver.get("http://www.bbc.com")

The error:
Traceback (most recent call last):

  File "<ipython-input-1-84256e62b8db>", line 5, in <module>
    driver = webdriver.Chrome('/Users/williamneal/Scratch/Titanic/chromedriver')

  File "/Users/williamneal/anaconda/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()

  File "/Users/williamneal/anaconda/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)

  File "/Users/williamneal/anaconda/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)

  File "/Users/williamneal/anaconda/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)

OSError: [Errno 8] Exec format error

There is a potential solution here, which involves installing Chrome Drivers via Home Brew but that option is not available to me.

Any ideas?

Asked By: user6204921

||

Answers:

Looks like this is complaining about the format of chromedriver binary.
It might be because of platform and chromedriver format mismatch. For example windows requires chromedriver.exe while there are different formats for linux and mac.

If you don’t want to install through package manager, just download chromedriver from
https://sites.google.com/chromium.org/driver/

Note : Choose file as per your os

Then place it anywhere on the os and pass that path as an argument. You can also set webdriver.chrome.driver environment variable if you don’t want to pass the location every time.

Answered By: Satish Gupta

FYI you could also encounter this issue if you did not unzip the chromedriver before adding it to your PATH.

Answered By: janDro
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.