Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97054
| From | Akira Li <4kir4.1i@gmail.com> |
|---|---|
| Subject | Re: Modify environment variable for subprocess |
| Date | 2015-09-24 03:12 +0300 |
| References | <6f8c6233-9777-488f-9026-fec729fef6d1@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.112.1443053508.28679.python-list@python.org> (permalink) |
loial <jldunn2000@gmail.com> writes:
> I need to modify the LIBPATH environment variable when running a
> process via subprocess, but otherwise retain the existing environment.
>
> Whats the best way to do that?
Pass env=dict(os.environ, LIBPATH=value) parameter:
import os
import subprocess
subprocess.check_call('echo $LIBPATH', shell=True,
env=dict(os.environ, LIBPATH='/some/path'))
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Modify environment variable for subprocess loial <jldunn2000@gmail.com> - 2015-09-23 02:51 -0700 Re: Modify environment variable for subprocess Cameron Simpson <cs@zip.com.au> - 2015-09-23 20:00 +1000 Re: Modify environment variable for subprocess Laura Creighton <lac@openend.se> - 2015-09-23 12:37 +0200 Re: Modify environment variable for subprocess Akira Li <4kir4.1i@gmail.com> - 2015-09-24 03:12 +0300
csiph-web