# How to fix ImportError: cannot import name 'BaseSettings' from 'pydantic'

Pydantic v2 moved settings out of the main package. Install `pydantic-settings` and change the import to `from pydantic_settings import BaseSettings`. Keep `from pydantic import Field` as-is. That is the whole migration for this error.

## The exact error

```text
ImportError: cannot import name 'BaseSettings' from 'pydantic'
```

## Fix it

1. `python -m pip install pydantic-settings`
   Expected: installed

2. Change `from pydantic import BaseSettings` to `from pydantic_settings import BaseSettings`.
   Expected: import works

3. Add `pydantic-settings` to requirements.txt / pyproject.
   Expected: deploys stop breaking

## When this applies

pydantic v2 installed and code does `from pydantic import BaseSettings`

## When this does NOT apply

pydantic v1 (BaseSettings is right there; do not add pydantic-settings)

## Versions

pydantic v2

## Why it happens

v2 split settings into its own distribution to slim the core.

## Edge cases

pydantic-settings v1 is the v1-compat line; v2 line up with pydantic v2.
