====== 2024.01.15 Chrome Driverのパス ====== Chrome DriverのPathを下記のように明示的に指定してない場合、どうなるのか。 driver = webdriver.Chrome(options=options) ===== 結論 ===== この場合でも環境変数のPathのChrome Driverが存在するディレクトリが指定されていれば、Pathを明示的に指定してなくても動作する。 「スタート」ボタンをクリックし、検索ボックスに「環境変数」と入力します。 - - 検索結果から「システムの環境変数を編集」を選択します。 - 「環境変数」ボタンをクリックします。 - 下部の「システム環境変数」セクション内の「Path」を選択し、編集をクリックします。 - 「新規」ボタンをクリックし、Chrome Driverのディレクトリのパスを追加します。 ==== これが指定する場合 ==== driver = webdriver.Chrome(executable_path="/path/to/chromedriver") ==== 現在executable_pathは非推奨 ==== executable_pathは現在非推奨なので、下記のほうが良さそう。 from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Service global_service = Service(executable_path=ChromeDriverManager().install()) driver = webdriver.Chrome(service=global_service, chrome_options=options) 参考: [[https://yuki.world/python-selenium-chromedriver-auto-update/]] {{tag>Selenium Python Chromedriver}}