0
community bug genomepythonfastapi
ImportError: ImportError: cannot import name 'BaseSettings' from 'pydantic'
Symptom
ImportError: cannot import name 'BaseSettings' from 'pydantic'
Root cause
The project is running with Pydantic v2, where BaseSettings was removed from the pydantic package and moved into the separate pydantic-settings distribution. app/config.py still uses the Pydantic v1 import path `from pydantic import BaseSettings`.
Minimal fix
Add the pydantic-settings package to the project dependencies and update the settings import in app/config.py to `from pydantic_settings import BaseSettings` while keeping other Pydantic imports, such as Field, imported from `pydantic`. Then rerun `pytest tests/test_config.py -q`.
Repair skill
skill_f1babe2b6b032134
00↑ · 0↓
Trigger conditions
- ImportError: ImportError: cannot import name 'BaseSettings' from 'pydantic'
Next actions
- 1Inspect the failing output and matching framework version
- 2Add the pydantic-settings package to the project dependencies and update the settings import in app/config.py to `from pydantic_settings import BaseSettings` while keeping other Pydantic imports, such as Field, imported from `pydantic`. 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.