[Bot]: pydantic error
Closed this issue · 3 comments
我在启动mcdr时bot未能正常启用,我报告给ai,他说在加载 bot@1.1.5 插件时,出现了一个类型错误。错误发生在 fastapi_manager.py 文件的 LocationModel 类定义中,具体是 conlist 函数调用时出现了问题。错误信息提示 conlist() 函数收到了一个意外的关键字参数 min_length。这可能是因为 conlist 函数的定义中并没有 min_length 参数,或者 conlist 函数的调用方式不正确。
这是部分日志:
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 bot@1.1.5 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 location_marker@1.3.2 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 minecraft_command_register@2.13.1 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 minecraft_data_api@1.5.0 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 more_command_nodes@1.1.2 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 online_player_api@1.0.0 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 player_last_play@1.1.1 已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 插件 where_is@2.2.1 已加载
[MCDR] [19:39:04] [TaskExecutor/ERROR]: Fail to load the entry point of bot@1.1.5
Traceback (most recent call last):
File "C:\Users\16199\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcdreforged\plugin\type\multi_file_plugin.py", line 86, in _on_ready
self._load_entry_instance()
File "C:\Users\16199\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcdreforged\plugin\type\regular_plugin.py", line 79, in _load_entry_instance
self.entry_module_instance = self._import_entrypoint_module()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\16199\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcdreforged\plugin\type\multi_file_plugin.py", line 51, in import_entrypoint_module
mod = importlib.import_module(self.get_metadata().entrypoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\16199\AppData\Local\Programs\Python\Python312\Lib\importlib_init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1381, in _gcd_import
File "", line 1354, in _find_and_load
File "", line 1325, in _find_and_load_unlocked
File "", line 929, in _load_unlocked
File "", line 994, in exec_module
File "", line 488, in call_with_frames_removed
File "plugins\Bot-v1.1.5.mcdr\bot_init.py", line 1, in
from bot.plugin import Plugin
File "plugins\Bot-v1.1.5.mcdr\bot\plugin.py", line 11, in
from bot.fastapi_manager import FastAPIManager
File "plugins\Bot-v1.1.5.mcdr\bot\fastapi_manager.py", line 15, in
class LocationModel(BaseModel):
File "plugins\Bot-v1.1.5.mcdr\bot\fastapi_manager.py", line 16, in LocationModel
position: conlist(float, min_length=3, max_length=3)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: conlist() got an unexpected keyword argument 'min_length'
[MCDR] [19:39:04] [TaskExecutor/INFO] [where_is]: 配置文件已加载
[MCDR] [19:39:04] [TaskExecutor/INFO] [location_marker]: 配置文件已加载
[MCDR] [19:39:04] [TaskExecutor/INFO] [player_last_play]: 配置文件已加载
[MCDR] [19:39:04] [TaskExecutor/INFO] [player_last_play]: 配置文件已加载
[MCDR] [19:39:04] [TaskExecutor/INFO]: 共加载: 9 个插件; 加载失败: 1 个插件; 已加载插件数: 11
[MCDR] [19:39:04] [MainThread/INFO]: 正在启动服务端,启动参数为 'start.bat'
[MCDR] [19:39:04] [MainThread/INFO]: 服务端正在以 PID 21672 运行中
[Server]
[Server] E:\GVS_Minecraft server start\server>"C:\Program Files\Java\zulu21\bin\java.exe" -Xms1G -Xmx6G -XX:+UseG1GC -X
[Server] Starting net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture
[MCDR] [19:39:05] [CheckUpdate/INFO]: MCDR 已为最新版
[Server] [19:39:18] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
[Server] [19:39:18] [Server thread/WARN]: While this makes the game possible to play without internet access, it also o.
[Server] [19:39:18] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
[Server] [19:39:18] [Server thread/INFO]: Preparing level "world"
[Server] [19:39:18] [Server thread/INFO]: [CM] Loaded 1 settings from carpet.conf
[Server] [19:39:19] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[Server] [19:39:20] [Worker-Main-9/INFO]: Preparing spawn area: 0%
[Server] [19:39:20] [Server thread/INFO]: Time elapsed: 443 ms
[Server] [19:39:20] [Server thread/INFO]: Done (1.454s)! For help, type "help"
[Server] [19:39:20] [Server thread/INFO]: Starting remote control listener
[MCDR] [19:39:20] [TaskExecutor/ERROR]: Error invoking listener EventListener(plugin='bot@1.1.5', callback=<function Ev)
Traceback (most recent call last):
File "C:\Users\16199\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcdreforged\plugin\plugin_manager.py",r
listener.execute(listener.plugin.server_interface, *args)
File "C:\Users\16199\AppData\Local\Programs\Python\Python312\Lib\site-packages\mcdreforged\plugin\plugin_event.py", le
return self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "plugins\Bot-v1.1.5.mcdr\bot\event_handler.py", line 24, in on_server_startup
for bot in plugin.bot_manager.bots.values():
^^^^^^
NameError: name 'plugin' is not defined
请提供安装的 pydantic 版本
我不记得这个插件有py包要求
PS C:\Users\16199> pip install pydantic
Requirement already satisfied: pydantic in c:\users\16199\appdata\local\programs\python\python312\lib\site-packages (1.10.13)
Requirement already satisfied: typing-extensions>=4.2.0 in c:\users\16199\appdata\local\programs\python\python312\lib\site-packages (from pydantic) (4.8.0)
[notice] A new release of pip is available: 23.3.1 -> 24.1.2
[notice] To update, run: python.exe -m pip install --upgrade pip
我不记得这个插件有py包要求 PS C:\Users\16199> pip install pydantic 已满足要求: pydantic in c:\users\16199\appdata\local\programs\python\python312\lib\site-packages (1.10.13) 要求已满足: typing-extensions>=4.2.0 in c:\users\16199\appdata\local\programs\python\python312\lib\site-packages (from pydantic) (4.8.0)
[注意事项]pip 的新版本可用: 23.3.1 -> 24.1.2 [注意] 要更新,请运行: python.exe -m pip install --upgrade pip
如你所见,它是23.3.1