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

Mint Linux下Selenium+Python无法找到Chrome binary问题求助

解决Selenium在Mint Linux下"cannot find Chrome binary"错误

错误核心

报错unknown error: cannot find Chrome binary说明Selenium无法定位到Chrome浏览器的安装路径——要么未安装Chrome,要么Mint下Chrome的安装位置和Ubuntu不同,导致Selenium默认路径匹配失败。

分步解决方案

1. 确认Chrome是否已安装

打开终端执行:

google-chrome --version

如果无版本号返回,说明未安装Chrome,执行以下命令安装:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f

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

已安装Chrome的话,先找实际路径:

which google-chrome

通常输出为/usr/bin/google-chrome或/opt/google/chrome/google-chrome。

修改代码,给ChromeOptions添加路径配置:

import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager

s = Service(ChromeDriverManager().install())
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
# 替换成你查到的Chrome实际路径
chrome_options.binary_location = "/usr/bin/google-chrome"
browser = webdriver.Chrome(service=s, options=chrome_options)

browser.implicitly_wait(5)
browser.get("https://www.rahulshettyacademy.com/AutomationPractice")
browser.maximize_window()
print(browser.title)
action = ActionChains(browser)

3. 若安装的是Chromium

如果系统装的是Chromium而非Chrome,路径通常为/usr/bin/chromium-browser,只需将binary_location替换为该路径即可。

4. 验证版本匹配

执行google-chrome --version查看Chrome版本,确保webdriver-manager下载的ChromeDriver主版本和Chrome一致。若自动匹配异常,可手动指定版本:

s = Service(ChromeDriverManager(version="120.0.6099.109").install())

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 19:35:21