このページの翻訳:
- 日本語 (ja)
- English (en)
最近の更新
最近の更新
PythonでChrome Driverを読み込む時にエラーになる。
from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service options = Options() driver_path = ChromeDriverManager().install() print(f"ChromeDriver is installed at: {driver_path}") global_service = Service(driver_path) driver = webdriver.Chrome(service=global_service, options=options)
OSError: [WinError 193] %1 は有効な Win32 アプリケーションではありません。
driverのパスをprintfしてみると、THIRD_PARTY_NOTICES.chromedriverになってる。
C:\Users\s-matsui\.wdm\drivers\chromedriver\win64\132.0.6834.160\chromedriver-win32/THIRD_PARTY_NOTICES.chromedriver
そこで、Pathを修正するして、chromedriver.exeに変えてあげると動作しました。
from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service options = Options() driver_path = ChromeDriverManager().install() ## Pathを修正 driver_path = driver_path.replace("THIRD_PARTY_NOTICES.chromedriver", "chromedriver.exe") print(f"ChromeDriver is installed at: {driver_path}") global_service = Service(driver_path) driver = webdriver.Chrome(service=global_service, options=options)