Python configuration libraries

Updated Nov 2026

Python configuration libraries load application settings from environment variables, files, and command-line arguments. A settings loader reads each source in a fixed order of precedence and converts the raw strings into typed values. These libraries let apps and services run the same code in development, test, and production.

Popularity

python-dotenv has the most monthly downloads in this comparison, at 757.3M.

LibraryMonthly downloadsStarsLast releaseLicense
python-dotenv
757.3M
Not on GitHubOct 2026BSD-3-Clause
Pydantic Settings
487.7M
1.5KNov 2026MIT
Traitlets
144.9M
Not on GitHubAug 2026BSD-3-Clause
OmegaConf
38.8M
2.4KOct 2026BSD-3-Clause
ConfigArgParse
21.8M
Not on GitHubNov 2026MIT
Hydra
17.9M
Not on GitHubOct 2026MIT
django-environ
9.1M
Not on GitHubJun 2026MIT
python-decouple
7.3M
3.0KMar 2023MIT
Downloads: pypi, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryDotenv file loaderNested configuration mergeApplication CLI overrides
python-dotenvBuilt-inUnsupportedUnsupported
Pydantic SettingsBuilt-inBuilt-inBuilt-in
TraitletsUnsupportedBuilt-inBuilt-in
OmegaConfUnsupportedBuilt-inBuilt-in
ConfigArgParseUnsupportedUnsupportedBuilt-in
HydraUnsupportedBuilt-inBuilt-in
django-environBuilt-inUnsupportedUnsupported
python-decoupleBuilt-inUnsupportedUnsupported
Built-inNot supported

Libraries and code examples

Reads key-value pairs from a .env file and sets them as environment variables.

Downloads / mo
757.3M
Last release
1.2.4
License
BSD-3-Clause

Quickstart

From main.py
$ python -m pip install python-dotenv==1.2.4
from dotenv import load_dotenv

load_dotenv()

python-dotenv examples

From open-source projects on GitHub

Pydantic Settings

Loads application settings into typed models from ordered environment, file, and custom sources.

Downloads / mo
487.7M
Stars
1.5K
Last release
2.16.3
License
MIT

Strengths

  • Validates declared settings types. Validate configuration against a typed settings model.
  • Customizes source precedence. Order settings sources explicitly when the defaults do not fit.

Limitations

  • Dotenv rejects undeclared fields. Extra dotenv values raise validation errors under the default forbid policy.
  • Windows environment matching ignores case. case_sensitive cannot enforce environment-variable casing on Windows.

Quickstart

From pydantic_settings.md
$ python -m pip install pydantic-settings==2.16.3
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    app_name: str = "demo"

print(Settings().app_name)

Pydantic Settings examples

From open-source projects on GitHub

Provides a configuration system for Python applications.

Downloads / mo
144.9M
Last release
5.16.1
License
BSD-3-Clause

Quickstart

From config.html
$ python -m pip install traitlets==5.16.1
from traitlets import Integer
from traitlets.config import Config, Configurable

class App(Configurable):
    workers = Integer(2).tag(config=True)

print(App(config=Config({"App": {"workers": 4}})).workers)

Traitlets examples

From open-source projects on GitHub

Builds hierarchical configuration objects with interpolation, structured schemas, and configuration composition.

Downloads / mo
38.8M
Stars
2.4K
Last release
2.4.0
License
BSD-3-Clause

Strengths

  • Interpolates related settings lazily. Reference other configuration values and resolve them when accessed.
  • Validates structured configuration. Use dataclass or attrs schemas to validate assignments at runtime.

Limitations

  • Implicit conversions emit warnings. Use matching types or OmegaConf.update to request conversion explicitly.
  • Resolution in place removes expressions. Copy configuration before resolve when lazy references must be preserved.

Quickstart

From usage.html
$ python -m pip install omegaconf==2.4.0
from omegaconf import OmegaConf

cfg = OmegaConf.create({"server": {"port": 8000}})
print(cfg.server.port)

OmegaConf examples

From open-source projects on GitHub

ConfigArgParse

Extends argparse so options can also come from config files or environment variables.

Downloads / mo
21.8M
Last release
1.10.1
License
MIT

Quickstart

From configargparse.py
$ python -m pip install configargparse==1.10.1
import configargparse

parser = configargparse.ArgParser()
parser.add("--workers", type=int, default=2, env_var="WORKERS")
print(parser.parse_args(["--workers", "4"]).workers)

Provides a framework for configuring complex applications.

Downloads / mo
17.9M
Last release
1.3.8
License
MIT

Quickstart

From README.md
$ python -m pip install hydra-core==1.3.8
from hydra import compose, initialize

with initialize(version_base=None, config_path=None):
    cfg = compose(overrides=["+message=hello"])
print(cfg.message)

Hydra examples

From open-source projects on GitHub
def get_backend_config(backend="torch-default", overrides=[]):
    """Return default hydra config for a given attack."""
    with hydra.initialize(config_path="config/impl"):
        cfg = hydra.compose(config_name=backend, overrides=overrides)
        print(f"Loading backend {cfg.name}.")
    return cfg

Configures Django applications from environment variables in the twelve-factor style.

Downloads / mo
9.1M
Last release
0.14.0
License
MIT

Quickstart

From quickstart.html
$ python -m pip install django-environ==0.14.0
import environ

env = environ.Env(DEBUG=(bool, False))
print(env("DEBUG"))

django-environ examples

From open-source projects on GitHub

python-decouple

Looks up settings in environment variables and INI or dotenv files, with defaults and explicit casts.

Downloads / mo
7.3M
Stars
3.0K
Last release
3.8
License
MIT

Strengths

  • Environment values take precedence. Environment variables override matching settings-file values.
  • Casts values at lookup. Apply bool, int, or custom casts when retrieving a setting.

Limitations

  • Values start as strings. Request explicit casts when booleans, numbers, or lists are needed.
  • Missing required values raise errors. Provide a default or handle UndefinedValueError for missing settings.

Quickstart

From README.rst
$ python -m pip install python-decouple==3.8
from decouple import config

print(config("DEBUG", default=False, cast=bool))

python-decouple examples

From open-source projects on GitHub

FAQ

Pydantic Settings suits applications that validate settings against a typed model. python-dotenv suits scripts that only need the values from a .env file. OmegaConf and Hydra suit nested configurations with command-line overrides.

python-dotenv reads key-value pairs from a .env file and sets them as environment variables. It does not build typed settings models or merge nested configuration.

Pydantic Settings loads settings into typed models from environment variables, dotenv files, secrets files, and custom sources. It validates each value against the declared field types.

OmegaConf builds hierarchical configuration objects with interpolation between values, structured schemas, and recursive merging. Hydra builds configuration composition on top of it.

Hydra composes an application's configuration from modular groups and command-line overrides. It runs on OmegaConf and adds launch and multirun workflows.

For coding agents

Found your configuration library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official