You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ChromeDriver与Chrome版本不兼容问题求助(Selenium v4.6)

问题解决:ChromeDriver与Chrome浏览器版本不匹配

错误信息

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 116.0.5845.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe

问题代码

from selenium import webdriver
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

class ChromeAuto:
    def __init__(self):
        self.options = webdriver.ChromeOptions()
        self.options.add_experimental_option('excludeSwitches', ['enable-logging'])
        self.service = Service()
        self.chrome = webdriver.Chrome(service=self.service, options=self.options)
        self.chrome.implicitly_wait(20)

解决方案

尽管Selenium 4.6.0及以上自带ChromeDriver自动管理功能,但缓存或残留文件可能导致版本不匹配,按以下步骤处理:

  • 确认并升级Selenium版本
    执行命令查看当前版本:pip show selenium,若版本低于4.6.0,执行升级:pip install --upgrade selenium

  • 清理旧ChromeDriver缓存与残留
    删除系统中手动放置的旧ChromeDriver文件,同时清理Selenium缓存目录:
    Windows路径为C:\Users\<你的用户名>\.cache\selenium,删除该目录下的chromedriver文件夹

  • 强制重新匹配版本
    完成上述操作后重新运行代码,Selenium会自动下载与Chrome 116匹配的ChromeDriver

  • 手动指定ChromeDriver(备选方案)
    若自动管理仍失效,下载对应Chrome 116版本的ChromeDriver,修改代码中Service的路径:

    self.service = Service(executable_path=r"C:\你的chromedriver路径\chromedriver.exe")
    

内容的提问来源于stack exchange,提问作者Gabriel Passos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 05:45:02