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

Linux Mint中chromedriver_autoinstaller报错:No chrome executable found on PATH

解决Linux Mint下chromedriver_autoinstaller报错"ValueError: No chrome executable found on PATH"

错误原因

出现该错误的核心原因通常有两个:

  • chromedriver_autoinstaller或selenium默认会查找名为chrome的可执行文件,但你的系统中仅存在google-chrome命令
  • 系统层面配置的PATH未被Python运行环境(比如IDE、非终端启动的进程)加载

解决办法

方法一:在代码中指定Chrome二进制文件路径

直接告知selenium你的Chrome具体安装路径,步骤如下:

  1. 终端执行which google-chrome或which google-chrome-stable,获取实际路径(示例:/usr/bin/google-chrome)
  2. 修改代码添加Chrome选项:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import chromedriver_autoinstaller

chromedriver_autoinstaller.install()

# 配置Chrome选项,指定二进制文件路径
chrome_options = Options()
chrome_options.binary_location = "/usr/bin/google-chrome"  # 替换为你获取到的实际路径

driver = webdriver.Chrome(options=chrome_options)
driver.get("http://www.python.org")
assert "Python" in driver.title

方法二:创建软链接统一可执行文件名

给google-chrome创建名为chrome的软链接,让依赖库能匹配到对应文件:

sudo ln -s /usr/bin/google-chrome /usr/bin/chrome

执行完成后再运行原代码即可。

方法三:在代码中临时添加PATH

如果系统PATH未被Python环境加载,可以在代码中手动添加Chrome路径:

import os
from selenium import webdriver
import chromedriver_autoinstaller

# 将Chrome路径添加到环境变量PATH中
os.environ["PATH"] += ":/usr/bin/google-chrome"  # 替换为实际路径

chromedriver_autoinstaller.install()
driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 16:02:59