控制台日志输出截图:
Traceback (most recent call last):
File "D:\mirai-cli-1\bot.py", line 2, in
from graia.application import GraiaMiraiApplication, Session
File "D:\新建文件夹 (2)\lib\site-packages\graia\application__init__.py", line 18, in
from graia.application.event.lifecycle import ( # for init lifecycle events
File "D:\新建文件夹 (2)\lib\site-packages\graia\application\event\lifecycle.py", line 3, in
from graia.broadcast.entities.event import Dispatchable, BaseDispatcher
ImportError: cannot import name 'BaseDispatcher' from 'graia.broadcast.entities.event' (D:\新建文件夹 (2)\lib\site-packages\graia\broadcast\entities\event.py)
描述你遇到的问题: 无法运行python程序
复现步骤: 该 BUG 会在进行以下操作后出现: 1.启动python程序时
发生错误的代码 为文档-入门-安装并配置开发环境中的bot.py from graia.broadcast import Broadcast from graia.application import GraiaMiraiApplication, Session from graia.application.message.chain import MessageChain import asyncio
from graia.application.message.elements.internal import Plain from graia.application.friend import Friend
loop = asyncio.get_event_loop()
bcc = Broadcast(loop=loop) app = GraiaMiraiApplication( broadcast=bcc, connect_info=Session( host="http://192.168.1.2:8080", # 填入 httpapi 服务运行的地址 authKey="INITKEYOrOSMXGG", # 填入 authKey account=1405789952, # 你的机器人的 qq 号 websocket=True # Graia 已经可以根据所配置的消息接收的方式来保证消息接收部分的正常运作. ) )
@bcc.receiver("FriendMessage") async def friend_message_listener(app: GraiaMiraiApplication, friend: Friend): await app.sendFriendMessage(friend, MessageChain.create([ Plain("Hello, World!") ]))
app.launch_blocking()
控制台日志输出截图: Traceback (most recent call last): File "D:\mirai-cli-1\bot.py", line 2, in
from graia.application import GraiaMiraiApplication, Session
File "D:\新建文件夹 (2)\lib\site-packages\graia\application__init__.py", line 18, in
from graia.application.event.lifecycle import ( # for init lifecycle events
File "D:\新建文件夹 (2)\lib\site-packages\graia\application\event\lifecycle.py", line 3, in
from graia.broadcast.entities.event import Dispatchable, BaseDispatcher
ImportError: cannot import name 'BaseDispatcher' from 'graia.broadcast.entities.event' (D:\新建文件夹 (2)\lib\site-packages\graia\broadcast\entities\event.py)
额外信息: