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

ChromeDriver版本匹配仍报错:误识别为113版本求助

解决ChromeDriver与Chrome版本不兼容问题

核心原因分析

undetected_chromedriver会自动下载匹配当前Chrome的驱动,但你的代码里指定了executable_path,存在驱动路径冲突或缓存残留问题,导致实际加载的始终是113版本驱动。

具体解决步骤

1. 彻底清理旧驱动残留

  • 删除以下路径中的ChromeDriver文件:
    • 你指定的路径C:\Users\no2si\Documents\CChromedriver\chromedriver.exe
    • 系统临时目录下以undetected_chromedriver开头的缓存文件夹(通常在C:\Users\no2si\AppData\Local\Temp)
  • 关闭所有Chrome进程,避免旧进程占用驱动文件。

2. 修改代码,让undetected_chromedriver自动匹配驱动

undetected_chromedriver本身支持自动下载对应版本的驱动,无需手动指定executable_path,修改相关方法:

def attach_to_existing_chrome(self):
    temp_dir = tempfile.mkdtemp()
    chrome_options = uc.ChromeOptions()
    chrome_options.add_argument(f"user-data-dir={temp_dir}")
    chrome_options.binary_location = r"C:\Users\no2si\Downloads\ch112 re\chrome-win\chrome.exe"
    # 移除executable_path参数,让库自动下载匹配的驱动
    return uc.Chrome(options=chrome_options)

def __init__(self, max_retries=3):
    self.driver = self.attach_to_existing_chrome()
    self.text_group_a = "text_group_a.txt"
    self.text_group_b = "text_group_b.txt"
    self.MAX_RETRIES = max_retries
    self.paused = False

主函数同步调整:

if __name__ == "__main__":
    text_group_a = """If I give you a sentence, process it according to the following conditions.
1. Among the words in the following sentences, change Nouns, pronouns, verbs, adjectives, and adverbs to easier words.

2. Keep Paragraph Line Breaks and Marks

here is the sentence: """
    chat_gpt_url = "https://chat.openai.com"
    chat_gpt = CustomChatGPT(max_retries=3)
    file_path = r"C:\Users\no2si\Downloads\eng\output2.txt"
    chat_gpt.automate_chat_gpt(chat_gpt_url, text_group_a, file_path)

3. 验证版本匹配

  • 打开指定的Chrome程序,在地址栏输入chrome://version/确认版本为112.0.5611.0
  • 运行代码后,查看undetected_chromedriver自动下载的驱动版本,确保与Chrome版本一致。

4. 额外排查

  • 检查系统环境变量Path,确保没有其他ChromeDriver路径优先级高于自动下载的驱动。

内容的提问来源于stack exchange,提问作者NO2 SIIZEXL

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 09:57:53