skillfed

python-decouple

Strict separation of settings from code.

python-decouple v3.8 8.8M downloads/30d#1,596 on PyPI3,039
Permissive license MIT DORMANT released

What it is and what it does

Python Decouple is a configuration management library that reads settings from environment variables, .env files, or ini files and makes them available to your Python code with optional type casting and default values. It solves the problem that environment variables are always strings—if you read DEBUG=False from an environment variable, a simple truthiness check will treat it as True because the string "False" is non-empty. Decouple lets you cast values to the correct type (bool, int, list, etc.) and define sensible defaults, so your code can safely assume the right data types.

Originally designed for Django, it has become a framework-agnostic tool used across web frameworks and general Python applications. It respects Unix convention by checking environment variables first, then falling back to config files, then to defaults you provide. The library is lazy—it only opens and parses config files when first needed—and supports UTF-8 encoding by default with the option to specify another.

Use it for:

  • Store database credentials, API keys, and service URLs in .env files without committing them to version control.
  • Toggle DEBUG mode and feature flags between development, staging, and production without redeploying code.
  • Configure email, cache, and logging backends with environment-specific values in Django or Flask settings.
  • Cast port numbers, timeouts, and batch sizes from environment strings to integers in application initialization.
  • Define per-deployment hostnames and SSL settings that change between instances without code changes.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Reads configuration parameters from environment variables, .env files, or ini files, with type casting and default values, keeping settings separate from code.

Yes. This is a mature, stable library with no dependencies, low install friction, and no known vulnerabilities. It solves a real problem (type-safe configuration from environment) that most Python applications face. The dormant maintenance status is not a concern for a small, focused tool that does one thing well and has been Production/Stable since 2014. Install it if you need to manage settings separately from code.

Install

python-decouple on PyPI

pip

pip install python-decouple

uv

uv add python-decouple

poetry

poetry add python-decouple

Installing python-decouple

Before you install

Low install friction with no runtime dependencies. Maintenance is dormant (last release 2023-03-01, 1262 days ago), but the package is marked Production/Stable and has accumulated 3039 repository stars, suggesting it is mature and widely relied upon despite infrequent updates.

License in practice

MIT license is permissive, allowing commercial and private use with minimal restrictions—you may use, modify, and distribute the package freely provided you include the license notice.

Quickstart

pip install python-decouple

from decouple import config

DEBUG = config('DEBUG', default=False, cast=bool)
SECRET_KEY = config('SECRET_KEY')
EMAIL_PORT = config('EMAIL_PORT', default=25, cast=int)

Verify before relying

  • Whether the package actively maintains compatibility with modern Python versions beyond what classifiers indicate.
  • Performance characteristics when reading large numbers of configuration parameters.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,262 days since the last release
Last repo commit
First released
Downloads 8,769,852/month — #1,596 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python_decouple-3.8-py3-none-any.whl

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: FlaskIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Software Development :: Libraries

Tags

environment variable configurationsettings management from env filesconfig casting and defaults.env file loaderseparate settings from codeconfiguration management pythonenvironment-based config
configuration-managementenvironment-variablessettings-framework

More Libraries packages