Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.) Date: Sun, 03 Apr 2016 13:37:24 +1000 Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de iA9nU5vR5QcEEfKJAymazQMj/VIzqlG2yebLe8u1bp5A== Cancel-Lock: sha1:LAGTxMXgfA8/X5wTe80xFuQ31W0= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:" 60': 0.05; 'subject:skip:s 10': 0.05; '*not*': 0.07; '------------': 0.07; 'errors:': 0.09; 'os.environ': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'steps:': 0.09; 'python': 0.10; 'accordingly.': 0.13; '8bit%:26': 0.16; 'dictionary.': 0.16; 'pairs).': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:instance': 0.16; 'attribute': 0.18; 'absolute': 0.23; '(most': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'separate': 0.27; '(key': 0.29; 'subject:update': 0.29; 'that.': 0.30; 'code': 0.30; 'problem': 0.33; 'url:python': 0.33; 'traceback': 0.33; 'skip:- 10': 0.34; 'file': 0.34; 'clear': 0.35; 'quite': 0.35; 'problem.': 0.35; 'should': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; 'doing': 0.38; 'test': 0.39; 'subject:from': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'field': 0.60; 'collection': 0.60; 'url:3': 0.60; 'your': 0.60; 'believe': 0.66; 'subject:Get': 0.66; 'subject': 0.70; 'skip:\xe2 10': 0.70; '8bit%:27': 0.72; '8bit%:45': 0.84; '_o__)': 0.84; 'received:125': 0.84; 'misleading': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:106341 Hongyi Zhao writes: > I use the following code to update the os.environ with > subprocess.Popen Again, it is quite misleading to describe what you are doing as “update the os.environ with subprocess.Popen”. The ‘subprocess.Popen’ call *cannot* upsdate the Python process's ‘os.environ’. What you're doing is two quite separate steps: * Obtain a collection of items (key → value pairs). * Update a dictionary. Please be clear that's what you're doing because “update ‘os.environ’ with ‘subprocess.Popen’ is *not* that. > But, I meet the following errors: > > ------------ > Traceback (most recent call last): > File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/ > runjasp.py", line 125, in > os.environ.update(line.partition('=')[::2] for line in output.split > ('\0')) > AttributeError: 'Popen' object has no attribute 'split' > ------------------- So your problem is nothing to do with “update ‘os.environ’”. I have updated the Subject field accordingly. The problem you're encountering is only to do with ‘subprocess.Popen’. That should make it much easier to search for the documentation to understand the problem. -- \ “When people believe that they have absolute knowledge, with no | `\ test in reality, this [the Auschwitz crematorium] is how they | _o__) behave.” —Jacob Bronowski, _The Ascent of Man_, 1973 | Ben Finney