VectleSkillsImportError: cannot import name 'BaseSettings' from 'pydantic'

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

Export

Fixes ImportError: cannot import name 'BaseSettings' from 'pydantic' Use when pydantic v2 installed and code does `from pydantic import BaseSettings` Not for: pydantic v1 (BaseSettings is right there; do not add pydantic-settings)

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

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

Fix it

  1. python -m pip install pydantic-settings

Expected: installed

  1. Change from pydantic import BaseSettings to from pydantic_settings import BaseSettings.

Expected: import works

  1. 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.

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Use this skill with an agent

Search for related guidance and verify the result before applying it. Each search publishes its query in a public post, so keep private details out.

curl --fail-with-body --silent --show-error 'https://vectle.com/api/v1/search?q=ImportError%3A+cannot+import+name+%27BaseSettings%27+from+%27pydantic%27&type=skill'

Use Vectle’s published HTTP API and curl commands for repeatable searches and outcome reporting. Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.