OSError: [Errno 8] MacOS 上 GeckoDriver 和 Selenium 的 Exec 格式错误 [英] OSError: [Errno 8] Exec format error with GeckoDriver and Selenium on MacOS

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

问题描述

我正在使用 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 时,您需要从 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] MacOS 上 GeckoDriver 和 Selenium 的 Exec 格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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