How to Install pydantic in Python

v2.12.5 General Purpose Python >=3.9

Data validation using Python type hints

Install pip install pydantic

What is pydantic?

Data validation using Python type hints

Data validation using Python type hints.

Fast and extensible, Pydantic plays nicely with your linters/IDE/brain. Define how data should be in pure, canonical Python 3.9+; validate it with Pydantic.

We've recently launched Pydantic Logfire to help you monitor your applications. Learn more

Quick Start

Minimal example to get started with pydantic:

from pydantic import BaseModel

class User(BaseModel):
    id: int
    name: str
    email: str

user = User(id=1, name="Alice", email="[email protected]")
print(user.model_dump())

Installation

pip (standard)

pip install pydantic

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install pydantic

pip3

pip3 install pydantic

conda

conda install -c conda-forge pydantic

Poetry

poetry add pydantic

Dependencies

Installing pydantic will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import pydantic; print(pydantic.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing pydantic with pip.

ModuleNotFoundError: No module named 'pydantic'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install pydantic. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'pydantic' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install pydantic to install into the interpreter you are running.

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

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show pydantic and upgrade with pip install --upgrade pydantic.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install pydantic. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user pydantic

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pydantic

Runtime Errors

Common errors when using pydantic after installation.

pydantic.ValidationError

Cause: Input data does not match the model's type annotations or validators.

Fix: Call e.errors() for field-level detail. Each entry shows location, type, and message.

TypeError: unexpected keyword argument

Cause: A field name passed to the model constructor doesn't exist in the model definition.

Fix: Check model field names match what you're passing. Use model_config = ConfigDict(extra='forbid') to catch this at definition time.

Recent Releases

VersionReleased
2.13.0b3 2026-03-31
2.13.0b2 2026-02-24
2.13.0b1 2026-02-23
1.10.25 2025-12-18
1.10.26 2025-12-18

Full release history on PyPI →

Manage pydantic

Upgrade to latest version

pip install --upgrade pydantic

Install a specific version

pip install pydantic==2.12.5

Uninstall

pip uninstall pydantic

Check what is installed

pip show pydantic

Last updated: 2026-04-11 • Data from PyPI