python Selenium包中存在格式错误



我在Linux Debian 9和PyCharm上运行,用于web抓取;我目前使用Python 3.5作为解释器。

脚本如下:

from selenium import webdriver
import time
import datetime
from selenium.webdriver.common.keys import Keys

到目前为止,通过正确导入包,脚本运行良好;当我试图通过运行以下行来设置驱动程序时:

driver = webdriver.Firefox(executable_path='/home/quant/Desktop/DataDownload/venv/bin/geckodriver')

我收到以下错误消息,与格式问题有关:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/quant/Desktop/DataDownload/venv/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 157, in __init__
self.service.start()
File "/home/quant/Desktop/DataDownload/venv/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error

在网上浏览时,我发现这个问题可能是在可执行程序没有被正确解压缩和执行时出现的;为了做到这一点,我遵循了以下步骤,在终端上运行它们:

(1(.zip文件从github网站的官方存储库下载:

wget [here][1]

(2(解压缩文件:

cd /home/quant/Downloads
tar -xvzf geckodriver-v0.21.0-arm7hf.tar.gz

(3(使文件可执行:

chmod +x geckodriver

(4(将文件移动到以下路径:

mv geckodriver /home/quant/PycharmProject/DataDownloads/venv/bin/

有人能帮我弄清楚出了什么问题吗?

提前感谢大家!!

[Errno 8] Exec format error

这意味着您正在尝试运行为不同架构编译的geckodriver版本。。。您下载了ARM版本(geckodriver-v0.21.0-arm7hf.tar.gz(,并且很可能在x86/amd64计算机上运行。

解决方案:返回geckodriver发布页面,下载适用于您系统的正确版本:https://github.com/mozilla/geckodriver/releases.

例如,如果您正在运行64位Linux,则需要下载:geckodriver-v0.21.0-linux64.tar.gz

最新更新