OSError: [Errno 8] Exec format error with GeckoDriver and Selenium on MacOS
OSError: [Errno 8] Exec format error with GeckoDriver and Selenium on MacOS
我正在使用 firefox gecko 驱动程序制作一个机器人,我的机器人不断收到错误消息,我发现消息的来源是:
from selenium import webdriver
browser= webdriver.Firefox()
行。
我已将错误消息中提到的每个文件添加到路径,包括 gecko 驱动程序、firefox 和其他较小的文档。我完全不知所措
错误信息如下:
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
这可能是这个问题的答案,
当它显示类似内容时,无法加载您的 Firefox 配置文件。它可能丢失或无法访问。
实际问题是,Firefox 48.0 或更高版本不适用于 selenium 3.0.0 或更高版本。
所以请检查你的版本。
因此,要使其正常工作,您还需要使用最新的 selenium 和相应的 geckodriver 版本进行更新以解决此问题。
然后尝试基本命令,
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
这个错误信息...
OSError: [Errno 8] Exec format error
...暗示调用的 GeckoDriver 二进制格式不正确。
您的主要问题是 GeckoDriver 二进制格式与底层 操作系统 [=] 的 不兼容性 34=].
由于您使用的是 MacOS,因此您需要从 [=13= 下载 geckodriver-v0.23.0-macos.tar.gz ], untar/unzip 它并通过参数 executable_path
[ 提供 GeckoDriver 的 绝对路径如下:
from selenium import webdriver
browser= webdriver.Firefox(executable_path='/path/to/geckodriver')
我正在使用 firefox gecko 驱动程序制作一个机器人,我的机器人不断收到错误消息,我发现消息的来源是:
from selenium import webdriver
browser= webdriver.Firefox()
行。
我已将错误消息中提到的每个文件添加到路径,包括 gecko 驱动程序、firefox 和其他较小的文档。我完全不知所措
错误信息如下:
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
这可能是这个问题的答案,
当它显示类似内容时,无法加载您的 Firefox 配置文件。它可能丢失或无法访问。
实际问题是,Firefox 48.0 或更高版本不适用于 selenium 3.0.0 或更高版本。
所以请检查你的版本。
因此,要使其正常工作,您还需要使用最新的 selenium 和相应的 geckodriver 版本进行更新以解决此问题。
然后尝试基本命令,
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
这个错误信息...
OSError: [Errno 8] Exec format error
...暗示调用的 GeckoDriver 二进制格式不正确。
您的主要问题是 GeckoDriver 二进制格式与底层 操作系统 [=] 的 不兼容性 34=].
由于您使用的是 MacOS,因此您需要从 [=13= 下载 geckodriver-v0.23.0-macos.tar.gz ], untar/unzip 它并通过参数 executable_path
[ 提供 GeckoDriver 的 绝对路径如下:
from selenium import webdriver
browser= webdriver.Firefox(executable_path='/path/to/geckodriver')