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

Python Selenium Beta版Chrome驱动使用错误二进制路径如何解决

修改ChromeDriver搜索Chrome二进制路径的方案

优先使用脚本内配置的方式,不需要改动驱动、系统环境变量,兼容性最好,不会影响其他程序运行。

脚本内显式指定路径(推荐)

ChromeDriver默认搜索稳定版Chrome安装路径是内置逻辑,不需要修改驱动本身,只要在初始化Selenium WebDriver时,通过ChromeOptions传入Beta版的可执行文件路径即可覆盖默认搜索逻辑。

  • Selenium 4.x 版本写法(当前主流版本)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

chrome_options = webdriver.ChromeOptions()
# 显式指定Chrome Beta的程序路径
chrome_options.binary_location = r"C:\Program Files\Google\Chrome Beta\Application\chrome.exe"

# 若104版本ChromeDriver已加入系统环境变量,可省略Service配置
# driver_service = Service(executable_path=r"本地chromedriver.exe的存放路径")
driver = webdriver.Chrome(options=chrome_options)
  • Selenium 3.x 旧版本写法
from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = r"C:\Program Files\Google\Chrome Beta\Application\chrome.exe"
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r"本地chromedriver.exe的存放路径")

路径前加r是Python原生语法,用来取消字符串内反斜杠的转义作用,适配Windows路径格式,不要遗漏。

备选方案(不推荐)

可以修改系统内Chrome的默认程序关联指向Beta版安装路径,但这种修改是全局生效的,会影响所有调用Chrome的程序,容易触发其他兼容问题,远不如脚本内单独指定稳定可控。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.27 23:00:10