OSError: [Errno 8] Exec format error with GeckoDriver and Selenium on MacOS

This error message…

OSError: [Errno 8] Exec format error

…implies that the GeckoDriver binary which was invoked was not in proper format.

Your main issue is the incompatibility of the GeckoDriver binary format with respect to the underlying Operating System.

As you are on MacOS you need to download geckodriver-v0.23.0-macos.tar.gz from mozilla/geckodriver, untar/unzip it and provide the absolute path of the GeckoDriver through the argument executable_path as follows:

from selenium import webdriver

browser= webdriver.Firefox(executable_path="/path/to/geckodriver")

Leave a Comment