# Pydantic v2 "BaseSettings has been moved" in CI

> Fix the Pydantic v1-to-v2 "BaseSettings has been moved to pydantic-settings" error in CI - settings classes must now import from the separate pydantic-settings package.

Source: https://latchkey.dev/learn/python/python-pydantic-basesettings-moved-in-ci  
Updated: 2026-06-26

Pydantic v2 removed `BaseSettings` from the core package and relocated it to the separate `pydantic-settings` distribution. Code that still imports it from `pydantic` raises on import after the upgrade.

## Diagnose it: which interpreter and which environment?

```Terminal
which -a python python3 pip
python -c "import sys; print(sys.executable); print(sys.version)"
python -c "import sys; [print(p) for p in sys.path]"
pip list 2>/dev/null | head -20
```

> Runners ship several Pythons. A package installed by one interpreter and imported by another produces a module-not-found error that looks like a failed install.

## FAQ

### What causes Pydantic v2 "BaseSettings has been moved" in CI?

There are 2 common causes: basesettings imported from pydantic on v2 and pydantic-settings is not installed. In v2 the class lives in pydantic_settings, not pydantic, so the old import path no longer resolves.

### How do I fix Pydantic v2 "BaseSettings has been moved" in CI?

There are 2 fixes depending on which cause you have: install pydantic-settings and fix the import and pin pydantic v1 to defer the migration. Work through them in order, since the first is the most common.

### What does Pydantic v2 "BaseSettings has been moved" in CI actually mean?

After a pydantic 2.x upgrade, importing settings fails with "PydanticImportError: BaseSettings has been moved to the pydantic-settings package."

### How do I stop Pydantic v2 "BaseSettings has been moved" in CI happening again?

Track the pydantic v2 migration guide when bumping the major version. The prevention section lists 3 changes that keep it from recurring.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
