8

I am using Sagemaker notebook and when importing vaex, I am getting the below error. the version of vaex I'm using is 4.16.0

PydanticImportError: BaseSettings has been moved to the pydantic-settings package. See https://docs.pydantic.dev/2.0.2/migration/#basesettings-has-moved-to-pydantic-settings for more details.

For further information visit https://errors.pydantic.dev/2.0.2/u/import-error

Anyone knows how to solve this?

I tried downgrading the pydantic library while installing vaex but that didn't help.

Kailash M S
  • 81
  • 1
  • 2
  • Well, this is what happens, when package dependencies are not properly restricted to specific major versions. You said you _"tried downgrading the pydantic library"_. What exactly does that mean? Because I am pretty sure this error should not occur with Pydantic v1 installed. Also there is already a [bug report](https://github.com/vaexio/vaex/issues/2384) for this. – Daniil Fajnberg Jul 11 '23 at 18:12
  • Thank you for the bug report, I used the version mentioned in the report, and import works. Previously I was trying a different version of pydantic and that didn't work. – Kailash M S Jul 13 '23 at 06:00

2 Answers2

7

What i have done Migration Guide

pip install pydantic-settings

I replaced in my code:

# from pydantic import BaseSettings # OLD
from pydantic_settings import BaseSettings # NEW
M Btki
  • 71
  • 2
1

In pydantic-V2, Settings management has been moved to a separate package named pydantic-settings.

You can install it by pip install pydantic-settings.

If you still want to have V1-style settings management in V2, you can import it like:

from pydantic.v1 import BaseSettings
Hasan Ramezani
  • 5,004
  • 24
  • 30