While using Pythons subprocess
module I noticed it does not seem like environment variables are being set properly. The following is an example from an IPython session showing this:
In [21]: subprocess.check_output(["echo", "$DUMMY"], env={"DUMMY" : "321"}, shell=True)
Out[21]: b'\n'
In [22]: subprocess.check_output(["echo", "$DUMMY"], env={"DUMMY" : "321"})
Out[22]: b'$DUMMY\n'
I get that the second one does not work, as it is not run by a shell. But the first one is the result you get when echoing a variable that is not set. So why does this not work? Or more probably, what am I doing wrong?