ChromeDriver仅支持114版本,与113版Chromium不兼容的Selenium Python问题
问题描述
以下是我的Selenium代码:
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from time import sleep driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) driver.get(input("Link: "))
数月后重新启动应用,发现Chromium已自动更新,当前ChromeDriver提示仅支持114版本,我手动安装了113.0.5672.63版ChromeDriver,但仍无法运行,报错如下:
[29728:29416:0809/171603.204:ERROR:chrome_browser_cloud_management_controller.cc(162)] Cloud management controller initialization aborted as CBCM is not enabled. DevTools listening on ws://127.0.0.1:52567/devtools/browser/abc399bf-e2a2-40b8-8c14-360ebee67372 Traceback (most recent call last): File "main.py", line 8, in <module> driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__ super().__init__( File "Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 56, in __init__ super().__init__( File "Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in __init__ self.start_session(capabilities) File "AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 290, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute self.error_handler.check_response(response) File "AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 113.0.5672.0 with binary path AppData\Local\Chromium\Application\chrome.exe Stacktrace: Backtrace: GetHandleVerifier [0x0078A813+48355] (No symbol) [0x0071C4B1] (No symbol) [0x00625358] (No symbol) [0x006461AC] (No symbol) [0x00641EF3] (No symbol) [0x00640579] (No symbol) [0x00670C55] (No symbol) [0x0067093C] (No symbol) [0x0066A536] (No symbol) [0x006482DC] (No symbol) [0x006493DD] GetHandleVerifier [0x009EAABD+2539405] GetHandleVerifier [0x00A2A78F+2800735] GetHandleVerifier [0x00A2456C+2775612] GetHandleVerifier [0x008151E0+616112] (No symbol) [0x00725F8C] (No symbol) [0x00722328] (No symbol) [0x0072240B] (No symbol) [0x00714FF7] BaseThreadInitThunk [0x75B07D59+25] RtlInitializeExceptionChain [0x7728B79B+107] RtlClearBits [0x7728B71F+191]
解决方法
指定ChromeDriverManager安装对应版本的驱动
修改代码,给ChromeDriverManager传入匹配当前Chromium版本的参数,强制安装对应驱动:driver = webdriver.Chrome(service=Service(ChromeDriverManager(driver_version="113.0.5672.63").install()))关闭Chromium自动更新,避免后续版本不匹配
- Windows系统:
- 运行
gpedit.msc打开组策略编辑器 - 导航到
计算机配置>管理模板>Google>Google Chrome>更新 - 启用
将自动更新设置为已禁用选项
- 运行
- Chromium绿色版:
找到chrome.exe右键创建快捷方式,在目标栏末尾添加--disable-background-networking参数,禁用后台更新。
- Windows系统:
手动指定ChromeDriver路径(无需依赖ChromeDriverManager)
将下载好的113.0.5672.63版ChromeDriver放到项目目录或系统PATH中,修改代码指定路径:# 替换为你的ChromeDriver实际路径 service = Service(executable_path=r"C:\your\path\to\chromedriver.exe") driver = webdriver.Chrome(service=service)
内容的提问来源于stack exchange,提问作者I'm una cosa
相关产品推荐
相关产品推荐

