subprocess & shared environments

Piet van Oostrum piet at
Fri May 1 09:45:29 CEST 2009

>>>>> Robert Dailey <rcdailey at> (RD) wrote:

>RD> I'm currently calling on a batch file (in Windows)
>RD> that sets a few environment variables that are needed by further
>RD> processes started via How can I persist the
>RD> environment modifications by the first call() function? I've done my
>RD> own searching on this and I came up with nothing.

Environments are propagated down the subprocess chain, not up. (I don't
know Windows good enough but I think this is also true on Windows.) What
you could do is have the batch file print the environment, read it in
your script and passing that environment to the other subprocesses. But
then why would you do it in a batch file? You could as well copy the
setting of the environment variables in your Python script. Or if the
batch file is supplied by another source, parse it and extract the
environment variables from it.
Piet van Oostrum <piet at>
URL: [PGP 8DAE142BE17999C4]
Private email: piet at

More information about the Python-list mailing list