导入 vaex 错误:PydanticImportError:“BaseSettings”已移至“pydantic-settings”包

Kai*_*M S 15 python amazon-sagemaker pydantic vaex

我正在使用 Sagemaker 笔记本,在导入 vaex 时,出现以下错误。我使用的vaex版本是4.16.0

PydanticImportError:BaseSettings已移至pydantic-settings包中。有关更多详细信息,请参阅https://docs.pydantic.dev/2.0.2/migration/#basesettings-has-moved-to-pydantic-settings

有关更多信息,请访问https://errors.pydantic.dev/2.0.2/u/import-error

有人知道如何解决这个问题吗?

我尝试在安装 vaex 时降级 pydantic 库,但这没有帮助。

小智 20

我做了什么 迁移指南

pip install pydantic-settings
Run Code Online (Sandbox Code Playgroud)

我在代码中替换了:

# from pydantic import BaseSettings # OLD
from pydantic_settings import BaseSettings # NEW
Run Code Online (Sandbox Code Playgroud)


Has*_*ani 5

在 中pydantic-V2,设置管理已移至名为 的单独包中pydantic-settings

您可以通过安装它pip install pydantic-settings

如果你仍然想在 中进行 V1 风格的设置管理V2,你可以像这样导入它:

from pydantic.v1 import BaseSettings
Run Code Online (Sandbox Code Playgroud)