Search code examples
pythonlinuxubuntuselenium-webdrivergeckodriver

Errno 8 EXEC Format Error using geckodriver 28 on FF 81 Ubuntu


I have 3 lines of code:

from selenium import webdriver
driver = webdriver.Firefox(executable_path= './geckodriver')
driver.get('http://wikipedia.org')

Whenever I run this, line 2 gives the error:

[Errno 8] Exec format error './geckodriver'

I've tried the following 64-bit geckodrivers 23, 24, 25, 26, 27, and 28 Ubuntu loaded Firefox 81.0.2 (64-bit)

So far, no dice.

This code works in my Windows environment with geckodriver 27 and Firefox 84.

Is there a trick to making it work on Linux?


Solution

  • This error message...

    [Errno 8] Exec format error './geckodriver'
    

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

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

    As you are on Ubuntu you need to download the latest geckodriver-v0.28.0-linux64.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')
    

    References

    You can find a couple of relevant detailed discussions in: