Pydantic >2.0.* seems to result in problems
Closed this issue · 2 comments
Describe the bug
When running my code (can't post it here), I get an import error from filip as a site package installed in an venv!
File "...", line 4, in <module>
from filip.models.ngsi_v2.iot import ServiceGroup
File ".../venv/lib/python3.7/site-packages/filip/__init__.py", line 4, in <module>
from filip.config import settings
File ".../venv/lib/python3.7/site-packages/filip/config.py", line 7, in <module>
from pydantic import BaseSettings, Field, AnyHttpUrl
File ".../venv/lib/python3.7/site-packages/pydantic/__init__.py", line 206, in __getattr__
return _getattr_migration(attr_name)
File ".../venv/lib/python3.7/site-packages/pydantic/_migration.py", line 280, in wrapper
'`BaseSettings` has been moved to the `pydantic-settings` package. '
pydantic.errors.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
I had to adjust some of the pathes in the error message, due to restricted information!
To Reproduce
Steps to reproduce the behavior:
pip install filip
- run any code that imports
BaseSettings
from Pydantic (in my case it wasServiceGroup
)
Environment (please complete the following information):
- OS: Windows 10
- Python-Version: 3.10, 3.9, 3.8, 3.7
- FiLiP-Version: 0.2.5
Additional context
In requirements.txt
and setup.py
the version of pydantic is just defined using >=
which is likely the cause. In pydantic v2.* there seems to be a change in the structure resulting in the ImportError above!
Maybe fixing it to pydantic~=1.10.11
(lastest v1 version) would solve the problem until v2 is more common!
At the moment in theory everyone installing filip into a new environment will end up with this error!
Branch 196-Pydantic-2-0-seems-to-result-in-problems created!