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

Windows11下Python Selenium运行Geckodriver报WinError216兼容错误

解决Win11下Geckodriver兼容性错误(WinError 216)

核心原因

你下载的是32位版本的geckodriver,而Windows11系统默认是64位架构,32位程序在该环境下会触发兼容性报错。

解决步骤

  • 下载64位版本的Geckodriver
    前往Mozilla的Geckodriver发布页,选择对应Windows系统的win64版本压缩包下载,不要选择win32版本。
  • 替换现有Geckodriver文件
    解压下载的win64版本压缩包,取出geckodriver.exe文件,替换掉你放在Python38文件夹下的旧32位版本。
  • 验证版本匹配
    确保Geckodriver版本和本地Firefox浏览器版本兼容:
    1. 打开Firefox,点击右上角菜单→帮助→关于Firefox,查看浏览器版本
    2. Geckodriver版本建议与Firefox主版本号对应(比如Firefox 120.x对应Geckodriver 120.x)
  • 确认路径配置
    确保Python38文件夹已添加到系统环境变量PATH中,让Selenium能正常找到geckodriver.exe。也可以在代码里直接指定路径:
    from selenium import webdriver
    from selenium.webdriver.firefox.service import Service
    
    service = Service(executable_path=r"C:\你的Python38路径\geckodriver.exe")
    driver = webdriver.Firefox(service=service)
    

额外检查

如果是通过pip安装的Selenium,确保版本为最新:

pip install --upgrade selenium

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 13:56:04