我正在苹果M1 mini上运行一个ubuntu 22.04 ARM64 UTM虚拟机。我试图使用以下代码片段在ARM64架构上通过python运行chromedriver:
from selenium import webdriver from selenium.webdriver.chrome.options import Options def myFunc(URL): webDriver = None try: chrome_driver_path = '/usr/bin/chromedriver' chromeOptions = Options() chromeOptions.add_argument("--headless=new") chromeOptions.add_argument("--start-maximized") chromeOptions.binary_location = chrome_driver_path webDriver = webdriver.Chrome(options=chromeOptions) <----- This line fails webDriver.get(URL) Do something.... except Exception as e: print(e) if webDriver != None: webDriver.close() webDriver = None return webDriver
我使用以下工具安装了铬和镀铬层: sudo apt-get安装铬驱动程序
铬和铬酸盐的版本是: 铬122.0.6261.94卡扣 ChromeDriver 122.0.6261.94(880dbf29479c6152d5e4f08dfd3a96b30f919e56参考文献/分支头/6261@{#960})
代码在指示行抛出异常: '无法使用Selenium Manager获取chrome的驱动程序。;有关此错误的文档,请访问: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
你可以从 XTRADEB ,(一个非官方的Ubuntu计划,旨在提供最新的软件和游戏包)。为此,您首先必须通过PPA获取存储库。您可以使用以下命令执行此操作: add-apt-repository ppa:xtradeb/apps -y (如果缺少add apt存储库,可以通过以下方式安装 apt-get install software-properties-common ). 然后,您可以通过以下方式安装铬 apt-get install chromium 然后,您还可以通过以下方式安装铬驱动程序 apt-get install chromium-driver 我的回答 here (对于arm64的selenium官方支持)可能对您也有用。
add-apt-repository ppa:xtradeb/apps -y
apt-get install software-properties-common
apt-get install chromium
apt-get install chromium-driver