OSError:[Errno 8] Mac OS上的GeckoDriver和Selenium出现执行格式错误 [英] OSError: [Errno 8] Exec format error with GeckoDriver and Selenium on MacOS

查看:298
本文介绍了OSError:[Errno 8] Mac OS上的GeckoDriver和Selenium出现执行格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用firefox gecko驱动程序制作一个机器人,我的机器人不断收到错误消息,并且发现消息的来源是:

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()

行.

我已将错误消息中提到的每个文件添加到路径,包括gecko驱动程序,firefox和其他较小的文档.我完全不知所措

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

这是错误消息:

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

推荐答案

此错误消息...

OSError: [Errno 8] Exec format error

...表示所调用的 GeckoDriver 二进制文件格式不正确.

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

您的主要问题是 GeckoDriver 二进制格式与基础操作系统不兼容.

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

MacOS 上时,您需要从geckodriver-v0.23.0-macos.tar.gz ./mozilla/geckodriver/releases"rel =" nofollow noreferrer> mozilla/geckodriver ,解压缩/解压缩并通过 GeckoDriver 提供绝对路径.参数 executable_path 如下:

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

这篇关于OSError:[Errno 8] Mac OS上的GeckoDriver和Selenium出现执行格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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