Path: csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'modify': 0.04; 'method.': 0.05; 'that?': 0.05; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'simpson': 0.16; 'subject:variable': 0.16; 'subprocess,': 0.16; 'wrote:': 0.16; 'variable': 0.18; 'cheers,': 0.22; 'pass': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'environment': 0.29; 'retain': 0.33; 'running': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'environment.': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'cameron': 0.66; 'direct': 0.68; 'received:61': 0.72; 'controllable': 0.84 X-Authentication-Info: Submitted using ID cskk@bigpond.com X-Authority-Analysis: v=2.0 cv=CsQ9gwED c=1 sm=1 a=RdxqkbulLQ60fYKT7Q76Zw==:17 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=ff-B7xzCdYMA:10 a=pGLkceISAAAA:8 a=nfqow0h7oDrP0yYiAugA:9 a=CjuIK1q_8ugA:10 a=RdxqkbulLQ60fYKT7Q76Zw==:117 Date: Wed, 23 Sep 2015 20:00:41 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: Modify environment variable for subprocess MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <6f8c6233-9777-488f-9026-fec729fef6d1@googlegroups.com> User-Agent: Mutt/1.5.23 (2014-03-12) References: <6f8c6233-9777-488f-9026-fec729fef6d1@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443003590 news.xs4all.nl 23764 [2001:888:2000:d::a6]:38549 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97032 On 23Sep2015 02:51, loial wrote: >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? Make a copy of os.environ, modify the copy, pass it via the env=parameter of subprocess.Popen. That is the most direct and controllable method. Cheers, Cameron Simpson Tachyon: A gluon that's not completely dry.