python-dotenv
raw JSON → 1.2.2 verified Tue May 12 auth: no python install: verified quickstart: stale
python-dotenv is a Python library that reads key-value pairs from a .env file and sets them as environment variables. The current version is 1.2.2, released in March 2026. The library is actively maintained with regular updates.
pip install python-dotenv Warnings
breaking Dropped support for Python 3.7; minimum required version is now Python 3.10. ↓
fix Upgrade your Python environment to version 3.10 or higher.
gotcha Importing dotenv directly instead of from dotenv import load_dotenv will result in ImportError. ↓
fix Use from dotenv import load_dotenv to import the function correctly.
gotcha The load_dotenv function does not override existing environment variables by default. ↓
fix Pass override=True to load_dotenv() if you want to override existing environment variables.
gotcha The dotenv run command now forwards flags directly to the specified command. ↓
fix Ensure that any flags intended for dotenv run are placed before the command to avoid unintended behavior.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.04s 17.9M
3.10 slim (glibc) - - 0.03s 18M
3.11 alpine (musl) - - 0.09s 19.8M
3.11 slim (glibc) - - 0.07s 20M
3.12 alpine (musl) - - 0.07s 11.6M
3.12 slim (glibc) - - 0.07s 12M
3.13 alpine (musl) - - 0.06s 11.3M
3.13 slim (glibc) - - 0.06s 12M
3.9 alpine (musl) - - 0.04s 17.4M
3.9 slim (glibc) - - 0.04s 18M
Imports
- load_dotenv wrong
import dotenvcorrectfrom dotenv import load_dotenv
Quickstart stale last tested: 2026-04-23
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
# Access environment variables
SECRET_KEY = os.environ.get('SECRET_KEY', '')
DATABASE_PASSWORD = os.environ.get('DATABASE_PASSWORD', '')
print(f'SECRET_KEY: {SECRET_KEY}')
print(f'DATABASE_PASSWORD: {DATABASE_PASSWORD}')