Skip to content

[Bug] 导入消息收集器失败: No module named 'prometheus_client' #60

@Einzieg

Description

@Einzieg

Plugin Version

Next-2.0.1

AstrBot Version

4.17.6

Database Type

MySQL

Operating System

Docker

Bug Description

[20:50:25.511] [Plug] [ERRO] [v4.17.6] [core.factory:112]: 导入消息收集器失败: No module named 'prometheus_client'

Traceback (most recent call last):

File "/AstrBot/main.py", line 130, in

asyncio.run(core_lifecycle.start())

│       │   │              └ <function InitialLoader.start at 0x7889b05b9ee0>

│       │   └ <astrbot.core.initial_loader.InitialLoader object at 0x7889b0b6bce0>

│       └ <function run at 0x788a18ed27a0>

└ <module 'asyncio' from '/usr/local/lib/python3.12/asyncio/__init__.py'>

File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run

return runner.run(main)

       │      │   └ <coroutine object InitialLoader.start at 0x7889b057a790>

       │      └ <function Runner.run at 0x788a18d37c40>

       └ <asyncio.runners.Runner object at 0x7889b10388f0>

File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run

return self._loop.run_until_complete(task)

       │    │     │                  └ <Task pending name='Task-4' coro=<InitialLoader.start() running at /AstrBot/astrbot/core/initial_loader.py:30> cb=[_run_until...

       │    │     └ <function BaseEventLoop.run_until_complete at 0x788a18d358a0>

       │    └ <_UnixSelectorEventLoop running=True closed=False debug=False>

       └ <asyncio.runners.Runner object at 0x7889b10388f0>

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 678, in run_until_complete

self.run_forever()

│    └ <function BaseEventLoop.run_forever at 0x788a18d35800>

└ <_UnixSelectorEventLoop running=True closed=False debug=False>

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 645, in run_forever

self._run_once()

│    └ <function BaseEventLoop._run_once at 0x788a18d37600>

└ <_UnixSelectorEventLoop running=True closed=False debug=False>

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1999, in _run_once

handle._run()

│      └ <function Handle._run at 0x788a18e81940>

└ <Handle Task.task_wakeup(<Future finished result=None>)>

File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run

self._context.run(self._callback, *self._args)

│    │            │    │           │    └ <member '_args' of 'Handle' objects>

Steps to Reproduce

更新后
启动后日志报错
web界面也无法打开

Expected Behavior

服务正常

Error Logs

astrbot  | [21:04:07.145] [Plug] [INFO] [core.patterns:320]: 注册服务: database_manager
astrbot  | [21:04:07.146] [Plug] [INFO] [core.factory:252]: 创建数据库管理器成功 (实现: SQLAlchemyDatabaseManager)
astrbot  | [21:04:07.224] [Plug] [ERRO] [v4.17.6] [core.factory:112]: 导入消息收集器失败: No module named 'prometheus_client'
astrbot  | Traceback (most recent call last):
astrbot  |
astrbot  |   File "/AstrBot/main.py", line 130, in <module>
astrbot  |     asyncio.run(core_lifecycle.start())
astrbot  |     │       │   │              └ <function InitialLoader.start at 0x7ab331069e40>
astrbot  |     │       │   └ <astrbot.core.initial_loader.InitialLoader object at 0x7ab38fe7c710>
astrbot  |     │       └ <function run at 0x7ab399a427a0>
astrbot  |<module 'asyncio' from '/usr/local/lib/python3.12/asyncio/__init__.py'>
astrbot  |
astrbot  |   File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
astrbot  |     return runner.run(main)
astrbot  |            │      │   └ <coroutine object InitialLoader.start at 0x7ab38feea790>
astrbot  |            │      └ <function Runner.run at 0x7ab3998a7c40>
astrbot  |<asyncio.runners.Runner object at 0x7ab331697830>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
astrbot  |     return self._loop.run_until_complete(task)
astrbot  |            │    │     │                  └ <Task pending name='Task-4' coro=<InitialLoader.start() running at /AstrBot/astrbot/core/initial_loader.py:30> cb=[_run_until...
astrbot  |            │    │     └ <function BaseEventLoop.run_until_complete at 0x7ab3998a58a0>
astrbot  |            │    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
astrbot  |<asyncio.runners.Runner object at 0x7ab331697830>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 678, in run_until_complete
astrbot  |     self.run_forever()
astrbot  |     │    └ <function BaseEventLoop.run_forever at 0x7ab3998a5800>
astrbot  |<_UnixSelectorEventLoop running=True closed=False debug=False>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 645, in run_forever
astrbot  |     self._run_once()
astrbot  |     │    └ <function BaseEventLoop._run_once at 0x7ab3998a7600>
astrbot  |<_UnixSelectorEventLoop running=True closed=False debug=False>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1999, in _run_once
astrbot  |     handle._run()
astrbot  |     │      └ <function Handle._run at 0x7ab3999f1940>
astrbot  |<Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
astrbot  |     self._context.run(self._callback, *self._args)
astrbot  |     │    │            │    │           │    └ <member '_args' of 'Handle' objects>
astrbot  |     │    │            │    │           └ <Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |     │    │            │    └ <member '_callback' of 'Handle' objects>
astrbot  |     │    │            └ <Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |     │    └ <member '_context' of 'Handle' objects>
astrbot  |<Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/initial_loader.py", line 30, in start
astrbot  |     await core_lifecycle.initialize()
astrbot  |           │              └ <function AstrBotCoreLifecycle.initialize at 0x7ab38fe2dee0>
astrbot  |<astrbot.core.core_lifecycle.AstrBotCoreLifecycle object at 0x7ab38fef4a70>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/core_lifecycle.py", line 201, in initialize
astrbot  |     await self.plugin_manager.reload()
astrbot  |           │    │              └ <function PluginManager.reload at 0x7ab331a30540>
astrbot  |           │    └ <astrbot.core.star.star_manager.PluginManager object at 0x7ab331a50800>
astrbot  |<astrbot.core.core_lifecycle.AstrBotCoreLifecycle object at 0x7ab38fef4a70>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/star/star_manager.py", line 462, in reload
astrbot  |     result = await self.load(specified_module_path)
astrbot  |                    │    │    └ None
astrbot  |                    │    └ <function PluginManager.load at 0x7ab331a305e0>
astrbot  |<astrbot.core.star.star_manager.PluginManager object at 0x7ab331a50800>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/star/star_manager.py", line 605, in load
astrbot  |     metadata.star_cls = metadata.star_cls_type(
astrbot  |     │        │          │        └ <class 'data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin'>
astrbot  |     │        │          └ Plugin astrbot_plugin_self_learning (Next-2.0.1) by NickMo: SELF LEARNING 自主学习插件 — 让 AI 聊天机器人自主学习对话风格、理解群组黑话、管理社交关系与好感度、自适应人格...
astrbot  |     │        └ None
astrbot  |     └ Plugin astrbot_plugin_self_learning (Next-2.0.1) by NickMo: SELF LEARNING 自主学习插件 — 让 AI 聊天机器人自主学习对话风格、理解群组黑话、管理社交关系与好感度、自适应人格...
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/main.py", line 117, in __init__
astrbot  |     self._lifecycle.bootstrap(
astrbot  |     │    │          └ <function PluginLifecycle.bootstrap at 0x7ab322682340>
astrbot  |     │    └ <data.plugins.astrbot_plugin_self_learning.core.plugin_lifecycle.PluginLifecycle object at 0x7ab322f9d430>
astrbot  |<data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin object at 0x7ab322ff45f0>
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/plugin_lifecycle.py", line 51, in bootstrap
astrbot  |     p.message_collector = p.service_factory.create_message_collector()
astrbot  |     │                     │ │               └ <function ServiceFactory.create_message_collector at 0x7ab322667060>
astrbot  |     │                     │ └ <data.plugins.astrbot_plugin_self_learning.core.factory.ServiceFactory object at 0x7ab322fa91c0>
astrbot  |     │                     └ <data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin object at 0x7ab322ff45f0>
astrbot  |<data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin object at 0x7ab322ff45f0>
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/factory.py", line 34, in wrapper
astrbot  |     result = func(self, *args, **kwargs)
astrbot  |              │    │      │       └ {}
astrbot  |              │    │       ()
astrbot  |              │    └ <data.plugins.astrbot_plugin_self_learning.core.factory.ServiceFactory object at 0x7ab322fa91c0>
astrbot  |<function ServiceFactory.create_message_collector at 0x7ab322666fc0>
astrbot  |
astrbot  | > File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/factory.py", line 103, in create_message_collector
astrbot  |     from ..services.core_learning import MessageCollectorService
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/core_learning/__init__.py", line 5, in <module>
astrbot  |     from .v2_learning_integration import V2LearningIntegration
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/core_learning/v2_learning_integration.py", line 38, in <module>
astrbot  |     from ..monitoring.instrumentation import monitored
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/monitoring/__init__.py", line 17, in <module>
astrbot  |     from .metrics import (
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/monitoring/metrics.py", line 11, in <module>
astrbot  |     from prometheus_client import CollectorRegistry, Counter, Gauge, Histogram
astrbot  |
astrbot  | ModuleNotFoundError: No module named 'prometheus_client'
astrbot  | [21:04:07.267] [Plug] [ERRO] [v4.17.6] [core.plugin_lifecycle:259]: 自学习服务初始化失败: 创建消息收集器失败: No module named 'prometheus_client'
astrbot  | [21:04:07.267] [Plug] [ERRO] [v4.17.6] [astrbot_plugin_self_learning.main:121]: 插件服务编排失败,部分功能将不可用: 创建消息收集器失败: No module named 'prometheus_client'
astrbot  | Traceback (most recent call last):
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/factory.py", line 103, in create_message_collector
astrbot  |     from ..services.core_learning import MessageCollectorService
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/core_learning/__init__.py", line 5, in <module>
astrbot  |     from .v2_learning_integration import V2LearningIntegration
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/core_learning/v2_learning_integration.py", line 38, in <module>
astrbot  |     from ..monitoring.instrumentation import monitored
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/monitoring/__init__.py", line 17, in <module>
astrbot  |     from .metrics import (
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/services/monitoring/metrics.py", line 11, in <module>
astrbot  |     from prometheus_client import CollectorRegistry, Counter, Gauge, Histogram
astrbot  |
astrbot  | ModuleNotFoundError: No module named 'prometheus_client'
astrbot  |
astrbot  |
astrbot  | During handling of the above exception, another exception occurred:
astrbot  |
astrbot  |
astrbot  | Traceback (most recent call last):
astrbot  |
astrbot  |   File "/AstrBot/main.py", line 130, in <module>
astrbot  |     asyncio.run(core_lifecycle.start())
astrbot  |     │       │   │              └ <function InitialLoader.start at 0x7ab331069e40>
astrbot  |     │       │   └ <astrbot.core.initial_loader.InitialLoader object at 0x7ab38fe7c710>
astrbot  |     │       └ <function run at 0x7ab399a427a0>
astrbot  |<module 'asyncio' from '/usr/local/lib/python3.12/asyncio/__init__.py'>
astrbot  |
astrbot  |   File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
astrbot  |     return runner.run(main)
astrbot  |            │      │   └ <coroutine object InitialLoader.start at 0x7ab38feea790>
astrbot  |            │      └ <function Runner.run at 0x7ab3998a7c40>
astrbot  |<asyncio.runners.Runner object at 0x7ab331697830>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
astrbot  |     return self._loop.run_until_complete(task)
astrbot  |            │    │     │                  └ <Task pending name='Task-4' coro=<InitialLoader.start() running at /AstrBot/astrbot/core/initial_loader.py:30> cb=[_run_until...
astrbot  |            │    │     └ <function BaseEventLoop.run_until_complete at 0x7ab3998a58a0>
astrbot  |            │    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
astrbot  |<asyncio.runners.Runner object at 0x7ab331697830>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 678, in run_until_complete
astrbot  |     self.run_forever()
astrbot  |     │    └ <function BaseEventLoop.run_forever at 0x7ab3998a5800>
astrbot  |<_UnixSelectorEventLoop running=True closed=False debug=False>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 645, in run_forever
astrbot  |     self._run_once()
astrbot  |     │    └ <function BaseEventLoop._run_once at 0x7ab3998a7600>
astrbot  |<_UnixSelectorEventLoop running=True closed=False debug=False>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1999, in _run_once
astrbot  |     handle._run()
astrbot  |     │      └ <function Handle._run at 0x7ab3999f1940>
astrbot  |<Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |   File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
astrbot  |     self._context.run(self._callback, *self._args)
astrbot  |     │    │            │    │           │    └ <member '_args' of 'Handle' objects>
astrbot  |     │    │            │    │           └ <Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |     │    │            │    └ <member '_callback' of 'Handle' objects>
astrbot  |     │    │            └ <Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |     │    └ <member '_context' of 'Handle' objects>
astrbot  |<Handle Task.task_wakeup(<Future finished result=None>)>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/initial_loader.py", line 30, in start
astrbot  |     await core_lifecycle.initialize()
astrbot  |           │              └ <function AstrBotCoreLifecycle.initialize at 0x7ab38fe2dee0>
astrbot  |<astrbot.core.core_lifecycle.AstrBotCoreLifecycle object at 0x7ab38fef4a70>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/core_lifecycle.py", line 201, in initialize
astrbot  |     await self.plugin_manager.reload()
astrbot  |           │    │              └ <function PluginManager.reload at 0x7ab331a30540>
astrbot  |           │    └ <astrbot.core.star.star_manager.PluginManager object at 0x7ab331a50800>
astrbot  |<astrbot.core.core_lifecycle.AstrBotCoreLifecycle object at 0x7ab38fef4a70>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/star/star_manager.py", line 462, in reload
astrbot  |     result = await self.load(specified_module_path)
astrbot  |                    │    │    └ None
astrbot  |                    │    └ <function PluginManager.load at 0x7ab331a305e0>
astrbot  |<astrbot.core.star.star_manager.PluginManager object at 0x7ab331a50800>
astrbot  |
astrbot  |   File "/AstrBot/astrbot/core/star/star_manager.py", line 605, in load
astrbot  |     metadata.star_cls = metadata.star_cls_type(
astrbot  |     │        │          │        └ <class 'data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin'>
astrbot  |     │        │          └ Plugin astrbot_plugin_self_learning (Next-2.0.1) by NickMo: SELF LEARNING 自主学习插件 — 让 AI 聊天机器人自主学习对话风格、理解群组黑话、管理社交关系与好感度、自适应人格...
astrbot  |     │        └ None
astrbot  |     └ Plugin astrbot_plugin_self_learning (Next-2.0.1) by NickMo: SELF LEARNING 自主学习插件 — 让 AI 聊天机器人自主学习对话风格、理解群组黑话、管理社交关系与好感度、自适应人格...
astrbot  |
astrbot  | > File "/AstrBot/data/plugins/astrbot_plugin_self_learning/main.py", line 117, in __init__
astrbot  |     self._lifecycle.bootstrap(
astrbot  |     │    │          └ <function PluginLifecycle.bootstrap at 0x7ab322682340>
astrbot  |     │    └ <data.plugins.astrbot_plugin_self_learning.core.plugin_lifecycle.PluginLifecycle object at 0x7ab322f9d430>
astrbot  |<data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin object at 0x7ab322ff45f0>
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/plugin_lifecycle.py", line 51, in bootstrap
astrbot  |     p.message_collector = p.service_factory.create_message_collector()
astrbot  |     │                     │ │               └ <function ServiceFactory.create_message_collector at 0x7ab322667060>
astrbot  |     │                     │ └ <data.plugins.astrbot_plugin_self_learning.core.factory.ServiceFactory object at 0x7ab322fa91c0>
astrbot  |     │                     └ <data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin object at 0x7ab322ff45f0>
astrbot  |<data.plugins.astrbot_plugin_self_learning.main.SelfLearningPlugin object at 0x7ab322ff45f0>
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/factory.py", line 34, in wrapper
astrbot  |     result = func(self, *args, **kwargs)
astrbot  |              │    │      │       └ {}
astrbot  |              │    │       ()
astrbot  |              │    └ <data.plugins.astrbot_plugin_self_learning.core.factory.ServiceFactory object at 0x7ab322fa91c0>
astrbot  |<function ServiceFactory.create_message_collector at 0x7ab322666fc0>
astrbot  |
astrbot  |   File "/AstrBot/data/plugins/astrbot_plugin_self_learning/core/factory.py", line 113, in create_message_collector
astrbot  |     raise ServiceError(f"创建消息收集器失败: {str(e)}")
astrbot  |<class 'data.plugins.astrbot_plugin_self_learning.exceptions.ServiceError'>
astrbot  |
astrbot  | data.plugins.astrbot_plugin_self_learning.exceptions.ServiceError: 创建消息收集器失败: No module named 'prometheus_client'

Relevant Configuration

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions