手动部署出现pydantic.errors
OS:ubuntu 24.04 & win11 python 3.13
手动部署2.2版本,安装相关依赖后,启动项目始终提示: pydantic.errors.PydanticUserError: model_config cannot be used as a model field name. Use model_config for model configuration.
依赖安装情况: 1、通过ubuntu中的宝塔面板部署,python版本:3.13、3.13.2均出现以上错误,查看默认安装了 pydantic 2.11.1,无法安装2.4.0 2、在windows中部署,也出现以上错误。 pydantic.errors.PydanticUserError: model_config cannot be used as a model field name. Use model_config for model configuration. For further information visit https://errors.pydantic.dev/2.11/u/model-config-invalid-field-name
降低python版本试试
C:\Users\Administrator\Desktop\FileCodeBox-master.venv\Lib\site-packages\pydantic_internal_config.py
\FileCodeBox-master.venv\Lib\site-packages\pydantic_internal_config.py
raw_annotations = namespace.get('annotations', {})
if raw_annotations.get('model_config') and config_dict_from_namespace is None:
raise PydanticUserError(
'model_config cannot be used as a model field name. Use model_config for model configuration.',
code='model-config-invalid-field-name',
)
在虚拟环境中,将pydantic_internal_config.py文件中的 if 注释掉就能正常启动项目
降低python版本试试