python-dotenv
Read key-value pairs from a .env file and set them as environment variables
Decision gist · record as of 2026-08-14
Yes. python-dotenv is a production-stable, zero-dependency utility with active maintenance, no known vulnerabilities, and permissive licensing. It solves a common development workflow problem cleanly and is widely adopted (top 100 PyPI by downloads). Install it if your application reads configuration from environment variables.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low friction installation with no runtime dependencies.
- Active maintenance with recent release (166 days ago) and strong repository signal (8845 stars).
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows use in commercial and private projects with minimal restrictions; retain license notice in distributions.
last release 2026-03-01 (166 days) · last repo commit 2026-07-26 · 8,845 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 740,099,887 downloads/mo, #41 on PyPI
Alternatives
Verify before relying
pip install python-dotenv
from dotenv import load_dotenv
load_dotenv() # reads .env file and sets variables in os.environ- Whether variable expansion supports nested references or only single-level interpolation.
- Performance characteristics when loading very large .env files.
- Behavior when .env file contains syntax errors or malformed entries.
What it is and what it does
python-dotenv is a lightweight library that reads configuration from a .env file and populates environment variables, designed for applications following 12-factor principles. It bridges the gap between development (where you want configuration in a file) and production (where configuration comes from the actual environment), allowing the same code to work in both contexts without modification.
The package provides two main patterns: `load_dotenv()` modifies `os.environ` directly, while `dotenv_values()` returns a dictionary without altering the environment. It supports variable expansion using POSIX syntax (e.g., `${DOMAIN}`), multiline values, comments, and quoted strings. An optional CLI tool allows manipulation of .env files without manual editing. The library has no runtime dependencies and installs cleanly across modern Python versions.
Use it for
- Load database credentials and API keys from .env during development without committing secrets to version control.
- Configure different settings for development, staging, and production by switching .env files or environment variables.
- Parse configuration from a stream (network, StringIO) instead of the filesystem for advanced deployment scenarios.
- Manage layered configuration by merging multiple .env files (shared, secret, environment-specific) into a single config dict.
- Use the CLI tool to set or list environment variables in .env without opening an editor.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
python-dotenv is a production-stable, zero-dependency utility with active maintenance, no known vulnerabilities, and permissive licensing. It solves a common development workflow problem cleanly and is widely adopted (top 100 PyPI by downloads). Install it if your application reads configuration from environment variables.
Install
python-dotenv on PyPI
Before you install
Low friction installation with no runtime dependencies. Active maintenance with recent release (166 days ago) and strong repository signal (8845 stars). Supports current Python versions from 3.10 through 3.14.
Requires Python 3.10 or later.
License in practice
BSD-3-Clause permissive license allows use in commercial and private projects with minimal restrictions; retain license notice in distributions.
Quickstart
pip install python-dotenv
from dotenv import load_dotenv
load_dotenv() # reads .env file and sets variables in os.environ
Verify before relying
- Whether variable expansion supports nested references or only single-level interpolation.
- Performance characteristics when loading very large .env files.
- Behavior when .env file contains syntax errors or malformed entries.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 166 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 740,099,887 / month, #41 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: PyPyTopic :: System :: Systems AdministrationTopic :: Utilities |
Evidence: python_dotenv-1.2.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
An agent finds packages by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language. Give your agent the search over MCP.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also django-dotenv · dotenv · dynaconf · load-dotenv · pytest-dotenv · poetry-dotenv-plugin · everett · django-environ · pytest-env · envier