python-dotenv: Load environment variables from .env files
Parse and load .env files into Python environments.
Learn more about python-dotenv
python-dotenv is a Python library for parsing and loading environment configuration from .env files into the process environment. It reads files using Bash-like syntax, supporting features such as variable expansion, multiline values, and quoted strings. The library provides both programmatic APIs (load_dotenv and dotenv_values functions) and a command-line interface for managing .env files. It is commonly used in development workflows to avoid hardcoding configuration values while maintaining compatibility with production systems that source configuration from actual environment variables.

Non-destructive loading
By default, load_dotenv does not override existing environment variables unless explicitly configured, allowing environment variables set outside the .env file to take precedence.
Multiple loading modes
Supports loading from filesystem paths, searching up the directory tree, or parsing from arbitrary streams such as StringIO objects, enabling configuration from various sources beyond .env files.
Bash-like syntax support
Implements Bash-compatible .env file parsing including variable expansion with ${VAR} syntax, multiline values, and quoted string handling, reducing the need to learn a separate configuration format.
from dotenv import load_dotenv
import os
# Load variables from .env file into environment
load_dotenv()
# Access environment variables
api_key = os.getenv('API_KEY')
database_url = os.getenv('DATABASE_URL')
print(f"Connected to: {database_url}")Adds support for reading .env files from Unix FIFOs; no breaking changes or new requirements.
- –Use FIFOs (named pipes) as .env sources on Unix systems for dynamic configuration injection.
- –CI now uses trusted publishing; no action required for users upgrading from v1.2.0.
Adds PYTHON_DOTENV_DISABLED env flag to skip load_dotenv() calls; Python 3.14 support added, project config moved to pyproject.toml.
- –Set PYTHON_DOTENV_DISABLED=1 to globally disable load_dotenv() without code changes (fixes #510).
- –Python 3.14 is now tested and supported; project metadata consolidated into pyproject.toml.
Patch release fixing Python 3.13 compatibility in find_dotenv and resolving a Windows CLI execution bug.
- –Upgrade if using Python 3.13, as find_dotenv now works reliably on that version.
- –Apply this release to fix execvpe failures when using the CLI on Windows systems.
Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
corepack
Enforces package manager versions specified in package.json.
clarity
TypeScript library for session replay and behavioral analytics.
posthog
Event tracking, analytics, and experimentation platform.
bun
Fast JavaScript runtime with built-in bundler and package manager.
moq
Mock .NET objects using lambda expressions and LINQ.