Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97034
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <lac@openend.se> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'modify': 0.04; 'that?': 0.05; 'leaks': 0.09; 'os.environ': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'wed,': 0.15; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'subject:variable': 0.16; 'subprocess,': 0.16; 'memory': 0.17; 'laura': 0.18; "shouldn't": 0.18; 'variable': 0.18; '2015': 0.20; 'skip:" 30': 0.20; 'sep': 0.22; 'import': 0.24; '-0700,': 0.29; 'received:se': 0.29; 'environment': 0.29; 'retain': 0.33; 'running': 0.34; 'add': 0.34; 'something': 0.35; 'problem.': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'environment.': 0.37; 'mac': 0.37; 'charset:us-ascii': 0.37; 'means': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'times': 0.63; 'header:In-reply-to:1': 0.84 |
| to | python-list@python.org |
| From | Laura Creighton <lac@openend.se> |
| Subject | Re: Modify environment variable for subprocess |
| In-reply-to | <6f8c6233-9777-488f-9026-fec729fef6d1@googlegroups.com> |
| References | <6f8c6233-9777-488f-9026-fec729fef6d1@googlegroups.com> |
| Comments | In-reply-to loial <jldunn2000@gmail.com> message dated "Wed, 23 Sep 2015 02:51:53 -0700." |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset="us-ascii" |
| Content-ID | <5089.1443004643.1@fido> |
| Content-Transfer-Encoding | quoted-printable |
| Date | Wed, 23 Sep 2015 12:37:23 +0200 |
| X-Greylist | Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Wed, 23 Sep 2015 12:37:24 +0200 (CEST) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.99.1443004647.28679.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1443004647 news.xs4all.nl 23840 [2001:888:2000:d::a6]:44643 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:97034 |
Show key headers only | View raw
In a message of Wed, 23 Sep 2015 02:51:53 -0700, loial 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? import subprocess, os my_env = os.environ # if your program should be able to modify the current env # otherwise my_env = os.environ.copy() # if it shouldn't # if you just want to add something to the existing LIBPATH my_env["LIBPATH"] = "/where/I/want/to/look/first:" + my_env["LIBPATH"] # otherwise my_env["LIBPATH"] = "/what/I/want" subprocess.Popen(my_program, env=my_env) Setting os.environ leaks memory under Mac OS and FreeBSD. I am not sure if this means that if you do this a gazillion times on a Mac you will have a problem. Laura
Back to comp.lang.python | Previous | Next — Previous in thread | Next 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