青龙面板运行selenium启动Chrome报错

Bug Description

在青龙面板运行selenium启动 Chrome 时,出现以下错误:

shell 复制代码
selenium.common.exceptions.WebDriverException: Message: chrome not reachable

这个错误信息表示 Chrome 浏览器无法被 Selenium 控制。

以下是python中对chrome的配置:

python 复制代码
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument('--single-process')
# 使用Selenium启动Chrome浏览器
driver = webdriver.Chrome(options=options)
print('Chrome启动成功')

Solution

后发现删除options.add_argument('--single-process')后,同时指定chromedriver对应路径,service = Service(executable_path='/usr/lib/chromium/chromedriver')后问题解决。我的青龙面板存在两个chromedriver,所以存在这个问题。

python 复制代码
service = Service(executable_path='/usr/lib/chromium/chromedriver')
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
# 使用Selenium启动Chrome浏览器
driver = webdriver.Chrome(options=options, service=service) 
print('Chrome启动成功')
相关推荐
曲幽4 小时前
刚部署的 LibreTranslate 频频翻车?我掏出了 20 年前的 StarDict 词典,用 FastAPI 搭了个本地词典翻译 API
python·fastapi·web·translate·goldendict·libretranslate·stardict·pystardict
荣码5 小时前
用Streamlit给AI应用套个界面,10行代码出Web页面
java·python
兵慌码乱14 小时前
基于Python+PyQt5+SQLite的药房管理系统实现:事务一致性与界面解耦全流程解析
python·sqlite·信号与槽·pyqt5·数据库设计·桌面应用开发·事务处理
金銀銅鐵16 小时前
[Python] 体验用欧几里得算法计算最大公约数的过程
python·数学
FreakStudio19 小时前
W55MH32L-EVB 上手测评:硬件 TCP/IP 加持的以太网单片机,MicroPython 零门槛开发
python·单片机·嵌入式·大学生·面向对象·并行计算·电子diy·电子计算机
用户03321266636721 小时前
使用 Python 从零创建 Word 文档
python
Csvn1 天前
Python 两大经典坑点 —— 可变默认参数 & 闭包延迟绑定
后端·python
曲幽1 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
用户556918817531 天前
#从脚本到独立程序:Python + Playwright 批量抓取的完整踩坑记录
python·自动化运维
兵慌码乱2 天前
基于 MediaPipe 与 PySide2 的手势交互音乐控制系统实现:轻量化视觉交互全流程解析
python·opencv·计算机视觉·人机交互·手势识别·mediapipe·pyside2