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下对应版本的文件夹,重新运行代码让工具自动下载匹配的驱动
- 打开Chrome,输入
验证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
相关产品推荐
相关产品推荐

