青龙面板运行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启动成功')
相关推荐
彦为君2 小时前
Agent 安全:从权限提示到沙箱隔离
python·ai·ai编程
PILIPALAPENG2 小时前
Python 语法速成指南:前端开发者视角(JS 类比版)
前端·人工智能·python
闫记康3 小时前
Linux学习day5
linux·chrome·学习
用户8356290780513 小时前
Python 操作 PowerPoint 页眉与页脚指南
后端·python
枫叶林FYL4 小时前
项目九:异步高性能爬虫与数据采集中枢 —— 基于 Crawl<sub>4</sub>AI 与 Playwright 的现代化数据采集平台 项目总览
爬虫·python·深度学习·wpf
猫猫的小茶馆4 小时前
【Python】函数与模块化编程
linux·开发语言·arm开发·驱动开发·python·stm32
Miss_min5 小时前
128K长序列数据生成
开发语言·python·深度学习
love530love5 小时前
MingLi-Bench 项目部署实录:基于 EPGF 架构的工程化实践
人工智能·windows·python·架构·aigc·epgf·mingli-bench
猿儿本无心5 小时前
快速搭建Python项目(Vscode+uv+FastAPI)
vscode·python·uv
嵌入式小站5 小时前
STM32 零基础可移植教程 05:按键消抖,为什么按一次会触发好几次
chrome·stm32·嵌入式硬件