我有一台来自AWS的带有ARM风味的EC2机器。我安装了Python3,然后使用pip3
安装Selenium。然后,我从这里下载了Linux版本的chrome驱动程序,解压缩它,并将chromedriver
文件保存在桌面中。当我尝试像这样运行代码时:
driver = webdriver.Chrome('/home/ec2-user/Desktop/chromedriver')
我知道这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/.local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
service_log_path, service, keep_alive)
File "/home/ec2-user/.local/lib/python3.7/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
self.service.start()
File "/home/ec2-user/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
creationflags=self.creationflags)
File "/usr/lib64/python3.7/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver'
知道怎么解决这个问题吗?可能是来自其他地方的Linux风格和chrome驱动程序的不同组合?
发布于 2022-03-26 19:39:37
这个错误信息..。
OSError: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver'
...implies表示您正在使用不正确的ChromeDriver可执行文件格式。
深潜
在使用AWS EC2 ARM风味时,您需要使用ChromeDriver的ARM64或ARM7变体。
此外,您似乎已经下载了ChromeDriver v100.x,其中谷歌铬的最新版本是Chrome版本99.0.4844.84
而且,您需要按照系统内安装的Google版本提供匹配的ChromeDriver版本。
解决方案
正如@Mark B
在他的评论中所指出的,您需要按照讨论在ARM上编译ChromeDriver下载ChromeDriver的匹配版本。
https://stackoverflow.com/questions/71626728
复制相似问题