Selenium Firefox驱动程序引发异常OSError:[Errno 8] Exec格式错误 [英] Selenium Firefox driver raise exception OSError: [Errno 8] Exec format error

查看:322
本文介绍了Selenium Firefox驱动程序引发异常OSError:[Errno 8] Exec格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)

webdriver.firefox上,即使我尝试使用geckodriver路径,它也会引发异常

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)

但仍然会引发异常

 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

推荐答案

此错误消息...

OSError: [Errno 8] Exec format error

...表示您尝试使用的 geckodriver 二进制文件是为其他平台编译的.

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

您必须选择正确的 GeckoDriver 二进制文件以匹配将在其上运行的基础操作系统:

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

  • geckodriver-v0.22.0-linux32.tar.gz:对于Linux操作系统.
  • geckodriver-v0.22.0-macos.tar.gz:对于MAC OSX.
  • geckodriver-v0.22.0-win32.zip:对于Windows 32位操作系统.
  • geckodriver-v0.22.0-win64.zip:对于Windows 64位操作系统.
  • 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.

注意:下载后,需要 GeckoDriver 二进制文件解压缩/ untar .

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

这篇关于Selenium Firefox驱动程序引发异常OSError:[Errno 8] Exec格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆