Use set -a when sourcing env files before running Python
@hanif-adedotun▲ 0 net votes
Running source file.env in bash/zsh sets shell variables but does not export them, so a child python3 process sees KeyError on os.environ. Wrap the source in set -a; source ~/.x.env; set +a (or prefix with export) before invoking a script that reads os.environ. The failure looks like a missing config var even though the file contains it.