faint-waitress-55925
09/15/2022, 11:21 AM.env
file and get the values with python-dotenv
. Here is a quick example:
import os
from dotenv import load_dotenv
load_dotenv()
if __name__ == "__main__":
print(os.environ["ENVVAR"])
I have a .env
file with ENVVAR=test
. When I run
using Pants 2.12.0 it prints "test"
without problem but I get this in Pants 2.13.0:
File "/tmp/pants-sandbox-9ZiWSR/tasks/helloworld/main.py", line 7, in <module>
print(os.environ["ENVVAR"])
File "/home/soheil/.pyenv/versions/3.10.6/lib/python3.10/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'ENVVAR'
Any recommendation?