4
votes

I am using firefox gecko driver to make a bot, I keep getting error messages with my bot and I have found that the source of the message is the:

from selenium import webdriver

browser= webdriver.Firefox()

lines.

I have added every file mentioned in the error message to path including gecko driver, firefox, and the other smaller documents. I am at a complete loss

Here is the error message:

Traceback (most recent call last):
  File "/usr/local/bin/fuckobot1.py", line 3, in <module>
    browser= webdriver.Firefox()

File "/Users/'myname'/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
    self.service.start()

File "/Users/'myname'/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child

raise child_exception
OSError: [Errno 8] Exec format error
2
This is probably happened due to using an executable that is not meant for your operation system, which OS are you using? - Fernando Irarrázaval G
I am using MacOS Sierra version 10.12.6 - PYANNANANA
And which executables are you using? - Fernando Irarrázaval G
i am using geckodriver version 0.23.0 - PYANNANANA
im very sorry, im a beginner that bit off more than he could chew by promising a friend that he would help him with a bot. - PYANNANANA

2 Answers

3
votes

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')
0
votes

This may be answer to this issue,
when it shows something like, Your Firefox profile cannot be loaded. It may be missing or inaccessible.
Actual problem is, Firefox 48.0 or greater not works with selenium 3.0.0 or greater version.
so please check your versions. so, to make it work you need to update with recent selenium and respective geckodriver version too that fixes this issue.

then try basic commands,

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

driver = webdriver.Firefox()