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

Selenium调用WebDriver出现OSError: [WinError 193] 问题求助

解决OSError: [WinError 193] %1 is not a valid Win32 application问题
  • 检查Chrome浏览器与ChromeDriver版本匹配

    • 打开Chrome,输入chrome://version/查看浏览器版本号
    • 确认webdriver-manager下载的ChromeDriver版本与浏览器完全一致,若版本不匹配,可手动指定版本安装:
      from selenium import webdriver
      from selenium.webdriver.chrome.service import Service as ChromeService
      from webdriver_manager.chrome import ChromeDriverManager
      
      driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager(version="你的Chrome版本号").install()))
      
    • 也可手动删除缓存目录C:\Users\[你的用户名]\.wdm\drivers\chromedriver\win64下对应版本的文件夹,重新运行代码让工具自动下载匹配的驱动
  • 验证Python与ChromeDriver架构匹配

    • 打开命令提示符,输入python -c "import sys; print(sys.maxsize > 2**32)"判断Python架构:返回True为64位,False为32位
    • 若Python为32位,需强制下载32位ChromeDriver:
      from selenium import webdriver
      from selenium.webdriver.chrome.service import Service as ChromeService
      from webdriver_manager.chrome import ChromeDriverManager
      from webdriver_manager.core.os_manager import OSType
      
      driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager(os_type=OSType.WIN32).install()))
      
  • 清理损坏的驱动文件

    • 删除缓存目录下的chromedriver.exe文件,重新运行代码触发重新下载
    • 或手动下载对应版本的ChromeDriver,将解压后的chromedriver.exe放到Python的Scripts目录,修改代码直接指定路径:
      from selenium import webdriver
      from selenium.webdriver.chrome.service import Service as ChromeService
      
      driver = webdriver.Chrome(service=ChromeService(r"你的chromedriver.exe完整路径"))
      
  • 检查系统环境与权限

    • 确认Python的Scripts目录已添加到系统环境变量PATH中
    • 右键以管理员身份运行Python脚本,避免权限不足导致驱动文件损坏

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 11:12:44