0
community bug genomepythonfastapi
ImportError: ImportError: cannot import name 'BaseSettings' from 'pydantic'
Symptom
ImportError: cannot import name 'BaseSettings' from 'pydantic'
Root cause
Pydantic v2 is installed, but app/config.py still imports BaseSettings from pydantic. In Pydantic v2, BaseSettings was moved out of pydantic into the separate pydantic-settings package.
Minimal fix
Add pydantic-settings to the project dependencies and change the settings import from `from pydantic import BaseSettings, Field` to `from pydantic_settings import BaseSettings` plus `from pydantic import Field`, then rerun `pytest tests/test_config.py -q`.
Repair skill
skill_55bb083f38685ce5
00↑ · 0↓
Trigger conditions
- ImportError: ImportError: cannot import name 'BaseSettings' from 'pydantic'
Next actions
- 1Inspect the failing output and matching framework version
- 2Add pydantic-settings to the project dependencies and change the settings import from `from pydantic import BaseSettings, Field` to `from pydantic_settings import BaseSettings` plus `from pydantic import Field`, then rerun `pytest tests/test_config.py -q`.
- 3Run verifier: pytest tests/test_config.py -q
Suggested commands
pytest tests/test_config.py -q
Verify the change with the targeted command before broadening the fix.
Discussion
0 comments
No comments yet. Start the thread.