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

求助:使用WebDriverManager启动ChromeDriver失败,提示找不到Chrome二进制文件

解决ChromeDriver启动时"cannot find Chrome binary"错误

可能的原因及对应解决方法:

1. 指定Chrome二进制文件路径

如果Chrome安装在非默认位置(比如自定义路径、便携版Chrome),需要在driver_options里手动指定Chrome的exe路径:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

driver_options = webdriver.ChromeOptions()
# Windows下示例(替换为你的实际路径)
driver_options.binary_location = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
# macOS下示例
# driver_options.binary_location = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
# Linux下示例
# driver_options.binary_location = "/usr/bin/google-chrome"

path_to_driver = ChromeDriverManager().install()
driver = webdriver.Chrome(service=Service(path_to_driver), options=driver_options)

2. 验证Chrome与ChromeDriver版本兼容性

虽然WebDriverManager会自动匹配版本,但偶尔会出现异常:

  • 打开Chrome,在地址栏输入chrome://version/查看版本号
  • 确认WebDriverManager安装的ChromeDriver版本与Chrome主版本一致(比如Chrome是125.x,Driver也需为125.x)
  • 可手动指定版本安装:
path_to_driver = ChromeDriverManager(version="125.0.6422.141").install()

3. 检查系统环境变量(Windows)

  • 将Chrome安装目录(如C:\Program Files\Google\Chrome\Application)添加到系统环境变量PATH中
  • 重启终端或IDE后重新运行代码

4. 处理便携版Chrome残留进程

如果使用便携版Chrome,需彻底关闭所有Chrome进程后,再启动Driver

5. 修复权限问题(Linux/macOS)

  • 给ChromeDriver添加可执行权限:
chmod +x /path/to/chromedriver
  • macOS下若提示无法打开,前往「系统设置-隐私与安全性」允许该文件运行

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 21:55:14