我有一臺來自 AWS 的帶有 ARM 風格的 EC2 機器。我安裝了 Python 3,然后用來pip3安裝 Selenium。然后我從這里下載了 chrome 驅動程式的 Linux 版本,解壓縮并將chromedriver檔案保存在 Desktop 中。當我嘗試運行這樣的代碼時:
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 驅動程式的不同組合?
uj5u.com熱心網友回復:
此錯誤訊息...
OSError: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver'
...表示您使用的ChromeDriver可執行檔案格式不正確。
深潛
當您使用 AWS EC2 ARM 風格時,您需要使用 ChromeDriver 的ARM64或ARM7變體。
此外,您似乎已經下載了 ChromeDriver v100.x作為最新版本谷歌瀏覽器是Chrome 版本 99.0.4844.84
![OSError: [Errno 8] Exec format error: '/home/ec2-user/Desktop/chromedriver' 在 AWS EC2 ARM 風味機器中使用 Chromedriver 時出錯](https://img.uj5u.com/2022/04/02/abb7d7989c3d4faab98c645e13f7043b.png)
并且您需要根據系統中已安裝的Google Chrome版本來匹配ChromeDriver的版本。
解決方案
正如他在評論@Mark B中指出的那樣,您需要根據討論在 ARM 上編譯 ChromeDriver下載匹配版本的ChromeDriver
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/454394.html
標籤:硒 硒网络驱动程序 亚马逊-ec2 硒铬驱动程序 selenium-webdriver-python
