I am running a python script that uses environment variables from a batch file. The variables are lost after the script is called. Here is an example of the code (example.py):
subprocess.Popen(env.cmd, shell=True).wait()
ENV_HOME = str(os.environ["ENV_HOME"])
I'm getting KeyError because ENV_HOME is not defined. I understand that I can use os.environ to set environment variables for my scripts to work, but env.cmd is a very large file that sets a lot of paths that I need for the python scripts to work. It's possible to read env.cmd into the python script, but since there are a lot of paths to set, I'm looking for an easier way to integrate the environment variables with the python script.
A workaround that I've been using is creating another cmd script:
call C:\Users\env.cmd
python example.py
ENV_HOME is defined if I use this process.