在使用selenium時出現FileNotFoundError: [WinError 2] 系統找不到指定的文件。


今天在使用selenium出現這樣的錯:

Traceback (most recent call last):
  File "E:\python\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "E:\python\lib\subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "E:\python\lib\subprocess.py", line 1017, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系統找不到指定的文件。

上網查了一下發現是找不到chromedriver。

然后使用下面的鏈接下載相應的chromedriver

http://npm.taobao.org/mirrors/chromedriver/

 

下載后解壓出 chromedriver.exe的文件,將其粘貼到自己python安裝的主目錄下或者python安裝目錄下的Scripts里就大功告成

 

下載的時候看錯了Chrom的版本,結果出現了如下錯:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 79

因為下載的chromedriver.exe版本比我的Chrom版本要高,解決辦法:列如我使用的Chrom版本是 78.0.3904.108,下載了一個78.0.3904.70.結果也能用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM