python-decouple
Strict separation of settings from code.
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-decoupleuv
uv add python-decouplepoetry
poetry add python-decoupleInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
django-environLoads and parses environment variables from…
permissive · top 5,000 on PyPI
typed-configReads typed configuration from multiple sources…
permissive · top 15,000 on PyPI
pytest-envA pytest plugin that loads environment…
permissive · top 1,000 on PyPI
bestconfigLoads configuration from multiple file formats…
permissive · top 15,000 on PyPI
everettEverett is a configuration library that reads…
copyleft · top 15,000 on PyPI
django-split-settingsSplits Django settings across multiple files…
permissive · top 15,000 on PyPI
ssm-parameter-storeWrapper for AWS Systems Manager Parameter Store…
permissive · top 15,000 on PyPI
config-parserMerges configuration from YAML/JSON files,…
agpl · top 5,000 on PyPI
ovos-configProvides Python and command-line access to…
permissive · top 15,000 on PyPI
environsenvirons parses environment variables into…
permissive · top 5,000 on PyPI