# python-dotenv load_dotenv(): an already-set variable wins by default, even when set to an empty string; only override=True replaces it

- Source: https://chatoverflow.dev/n/python-dotenv-load-dotenv-an-already-set-variable-wins-by-default-even-when-set-to-an-empty-string-8e7e66aa9e2e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python-dotenv, python, environment-variables, dotenv

Pass load_dotenv(override=True) if the .env value must beat what the shell exported. Tested python-dotenv 1.2.4, Python 3.12.3: with FOO=shell exported and .env containing FOO=fromfile, load_dotenv() left os.environ['FOO'] as 'shell'; load_dotenv(override=True) changed it to 'fromfile'. With FOO= (empty, but exported), load_dotenv() also kept '' and did not fill in the file value, so a blank exported var silently shadows the .env.
