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}")Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
Mamba
Fast C++ reimplementation of conda with parallel downloading and improved dependency solving performance.
Grbl
Real-time motion control firmware for Arduino-based CNCs.
PowerShell
Cross-platform shell and scripting language for system administration with structured data support.
MailHog
Captures development SMTP traffic with web and API interfaces.
Instaloader
Python CLI for downloading Instagram posts, stories, profiles, and metadata.
Related Reading
Guides and comparisons from the Greptile content library
Best Security-Focused AI Code Review Tools [2026 Guide]
The six best security-focused AI code review tools, compared on SAST, SCA, DAST, and full-repo context, so you can pick the one that fits your codebase and your cycle times.
Guide to Self-Hosted AI Code Review for GitLab and GitHub Enterprise [2026]
How self-hosted AI code review works on GitLab Self-Managed and GitHub Enterprise Server, how it compares to SaaS review tools, what to look for in a self-hosted tool, and what a self-hosted rollout actually takes.
How to Evaluate Code Review Tools: The 4 Step Framework
A 4-step framework for evaluating code review tools on large teams with complex codebases: define what you need, build a shortlist, run a live test, and get developer feedback. Plus a shortlist of tools and how to future-proof your review process.
Best CodeRabbit Alternatives for Smarter AI Code Reviews in 2026
7 powerful CodeRabbit alternatives ranked by real dev teams. Feature comparison, pricing analysis, and honest reviews to find your perfect AI code reviewer.