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

如何为Arch Linux安装配置Chromedriver以适配Selenium

解决Chromedriver安装配置及Selenium运行问题

一、核心前提:匹配Chromium与Chromedriver版本

Chromedriver必须和你的Chromium大版本完全一致(比如Chromium是120.x,Chromedriver也要120.x),这是避免多数错误的关键:

  • 查看Chromium版本:打开Chromium,地址栏输入chrome://version,复制「版本」栏的数字(如120.0.6099.109)
  • 下载对应版本的Chromedriver:找到对应系统的压缩包(如Linux 64位),解压后得到chromedriver可执行文件

二、安装配置Chromedriver

方法1:添加到系统路径(推荐,无需脚本指定路径)

  1. 移动chromedriver到系统默认可执行路径(以Linux为例):
    sudo mv chromedriver /usr/local/bin/
    
  2. 赋予执行权限:
    sudo chmod +x /usr/local/bin/chromedriver
    
  3. 验证:终端输入chromedriver --version,能显示版本号即配置成功

方法2:脚本中指定路径(临时测试用)

不想修改系统路径的话,直接在Python脚本里写Chromedriver的绝对路径:

from selenium import webdriver

driver = webdriver.Chrome(executable_path="/你的路径/chromedriver")
driver.get("https://www.example.com")

三、替代方案:用Selenium自动管理驱动(无需手动装Chromedriver)

Selenium 4.6及以上版本自带selenium-manager工具,能自动下载匹配的Chromedriver,完全不用手动处理路径:

  1. 确保Selenium是最新版本,不够就升级:
    pip install --upgrade selenium
    
  2. 直接初始化驱动即可,无需额外配置:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.example.com")

## 四、解决你遇到的报错
你看到的`(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)`错误,大概率是两个原因:
1. Chromedriver和Chromium版本不匹配
2. 系统找不到Chromium可执行文件(因为你装的是Chromium,不是Chrome)

针对第二个原因,脚本里指定Chromium路径即可:
```python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "/usr/bin/chromium-browser"  # 替换为你的Chromium实际路径
driver = webdriver.Chrome(options=options)
driver.get("https://www.example.com")

五、关于官方文档的疑问

官方文档默认用户具备基础系统配置知识,或默认使用最新版本Selenium(自带驱动管理),所以没详细提及这些入门配置。新手优先用Selenium 4.6+的自动驱动管理,能避开大部分路径、版本匹配问题。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 09:07:16