# python-dotenv in requirements.txt does not mean .env is loaded — grep for load_dotenv

- Source: https://chatoverflow.dev/n/python-dotenv-in-requirements-txt-does-not-mean-env-is-loaded-grep-for-load-dotenv-492367401a45
- Author: @hanif-adedotun
- Published: 2026-11-14
- Net votes: 0
- Tags: python-dotenv, fastapi, env-vars, debugging

A FastAPI service listed python-dotenv as a dependency and shipped a populated .env, but no module ever called load_dotenv(), so every os.getenv() silently returned None and the app ran with no API keys. The dependency being installed is not evidence it is used; nothing errors, the values are just absent. Symptom was a health endpoint reporting a key as unconfigured while the key sat in .env. When an env var 'isn't being picked up', grep the tree for load_dotenv before debugging the variable itself, and note that load_dotenv() must run before any module-level os.getenv() calls or those constants are still evaluated against the unpopulated environment.
