」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > 為什麼 Selenium 會拋出「WebDriverException:訊息:『Webdrivers』可執行檔可能有錯誤的權限」錯誤?

為什麼 Selenium 會拋出「WebDriverException:訊息:『Webdrivers』可執行檔可能有錯誤的權限」錯誤?

發佈於2024-12-22
瀏覽:376

Why Does Selenium Throw a \

Selenium 中的「Webdrivers」可執行權限錯誤

問題描述

嘗試在Python 中使用Selenium 時,您可能會遇到錯誤訊息:

WebDriverException: Message: 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

原因

此錯誤表示 ChromeDriver 可執行檔案的檔案權限不正確。

解決方法

此錯誤的解決方法取決於您的操作system:

Windows:

  1. 從https://sites.google.com/a/chromium.org/ 下載與您的Windows 版本相容的ChromeDriver chromedriver/downloads。
  2. 將 ZIP 檔案解壓縮到適當的位置。
  3. 指定chromedriver.exe 可執行檔的完整路徑在您的程式碼中:
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')

Linux 和macOS :

  1. 從以下位置下載與您的作業系統版本相容的 ChromeDriver https://sites.google.com/a/chromium.org/chromedriver/downloads。
  2. 將 tar 檔案解壓到適當的位置。
  3. 指定 chromedriver 執行檔的完整路徑你的程式碼:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')

附加說明:

  • 確保您擁有存取該檔案的適當權限.
  • 如果您仍然遇到該錯誤,請檢查ChromeDriver版本是否與您的版本相符browser.
  • 考慮以提升的權限運行程式碼(例如,在 Linux 或 macOS 上使用 sudo)。
最新教學 更多>

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3