> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/all/python/packages/dotenv.md).

# Environment Variables

```bash
pip install python-dotenv
```

`python-dotenv` reads key-value pairs from a `.env` file and sets them as environment variables

.env (git ignore this)

```
CONFIG_PATH=${HOME}/.config/foo
DOMAIN=example.org
EMAIL=admin@${DOMAIN}
```

script.py

```python
from dotenv import load_dotenv
import os

load_dotenv()

SECRET_KEY = os.getenv("EMAIL")
DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD")
```

flask run auto does this
