ChromeDriver下载报错求助:运行时浏览器无法正常启动
解决ChromeDriver无法找到对应版本的问题
问题原因:Chrome 115及以上版本发布后,谷歌调整了ChromeDriver的分发存储地址,旧版本的webdriver-manager(版本低于4.0)无法适配新地址,导致出现找不到驱动的错误。
解决方案1:升级webdriver-manager到最新版
- 先卸载旧版本:
pip uninstall webdriver-manager -y - 安装最新版本:
pip install webdriver-manager --upgrade - 升级完成后,你的原有代码无需修改,直接运行即可。
解决方案2:手动指定ChromeDriver版本
如果升级后仍有问题,或者需要指定特定版本的驱动:
- 查看你的Chrome浏览器版本:打开Chrome,输入
chrome://version/查看完整版本号(比如115.0.5790.170) - 修改代码,在
ChromeDriverManager中指定对应版本:import pyautogui from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from webdriver_manager.chrome import ChromeDriverManager from pynput.keyboard import Key, Controller from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = Options() # 替换为你的Chrome实际版本号 driver = webdriver.Chrome(service=Service(ChromeDriverManager(version="115.0.5790.170").install()), options=options)
解决方案3:手动下载并指定驱动路径
如果上述方法都无效,可直接手动下载驱动:
- 下载与你的Chrome版本完全匹配的ChromeDriver
- 将下载的驱动文件放到项目目录或指定路径
- 修改代码,直接指定驱动路径:
import pyautogui from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from pynput.keyboard import Key, Controller from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = Options() # 替换为你的ChromeDriver实际路径,Windows系统注意用双反斜杠或原始字符串 service = Service(executable_path="./chromedriver.exe") # Linux/macOS为"./chromedriver" driver = webdriver.Chrome(service=service, options=options)
内容的提问来源于stack exchange,提问作者fedordima
相关产品推荐
相关产品推荐

