Selenium Firefox driver raise exception OSError: [Errno 8] Exec format error

北慕城南 提交于 2019-12-11 18:33:52

问题


def setUp(self):
   display = Xvfb()
   display.start()
   fp = webdriver.FirefoxProfile()
   fp.set_preference("browser.download.folderList",2)
   fp.set_preference("browser.download.manager.showWhenStarting",False)
   fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv")
       self.browser= webdriver.Firefox(firefox_profile=fp)

On webdriver.firefox it raises an exception even I tried with geckodriver path

self.browser=webdriver.Firefox(executable_path='/usr/bin/geckodriver',firefox_profile=fp)

But still it raises an exception

 Traceback (most recent call last):
  File "fbCampaign.py", line 23, in setUp
    self.browser= webdriver.Firefox(executable_path='/usr/bin/geckodriver',firefox_profile=fp)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 157, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

回答1:


This error message...

OSError: [Errno 8] Exec format error

...means the geckodriver binary which you are trying to use was compiled for a different platform.

Solution

Download the GeckoDriver binary specific to your platform (Windows, Mac, Linux) from GeckoDriver Release Repository.

You must choose the correct GeckoDriver binary to match the underlying OS it will be run on:

  • geckodriver-v0.22.0-linux32.tar.gz: For Linux OS.
  • geckodriver-v0.22.0-macos.tar.gz: For MAC OSX.
  • geckodriver-v0.22.0-win32.zip: For Windows 32-bit OS.
  • geckodriver-v0.22.0-win64.zip: For Windows 64-bit OS.

Note: Once you download you need to unzip / untar the GeckoDriver binary.



来源:https://stackoverflow.com/questions/52490692/selenium-firefox-driver-raise-exception-oserror-errno-8-exec-format-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!