subprocess.call env var
19,202
You can use env
with call in the exact same way as with popen
:
subprocess.call(
["boto-rsync", "..."],
env={"PATH":"/Library/Frameworks/Python.framework/Versions/2.7/bin/"},
)
Author by
AliBZ
Updated on June 04, 2022Comments
-
AliBZ almost 2 years
I'm using Popen because I need the env, like this:
Popen( ["boto-rsync", "..."], env={"PATH":"/Library/Frameworks/Python.framework/Versions/2.7/bin/"}, )
The problem is
Popen
runs the command as a new thread. Is there any way that I could pass theenv
tosubprocess.call
or preventPopen
from creating a new thread? Thanx -
AliBZ almost 12 yearsThanx, I don't know why I didn't try it ! I think I couldn't find the option.
-
Colin D Bennett about 10 years@AliBZ the documentation for subprocess.call is not clear on that point -- the only indication that other keyword args are supported is the tiny little asterisk in
subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False)
-
jfs over 8 years@AliBZ: to be clear:
subprocess.call(cmd)
is justsubprocess.Popen(cmd).wait()
i.e., you may pass tocall()
all arguments that you may pass toPopen()
.