Re: Calling the source command from subprocess.popen to update the os.environ.

2016-03-27 Thread Hongyi Zhao
On Sun, 27 Mar 2016 13:24:05 +, Hongyi Zhao wrote: > # replace env > os.environ.clear() I find another method which can solve this issue, ie., changing the above code into the follows: # ref : http://unix.stackexchange.com/questions/178522/unsetting- environment-variable-with-an-empty-name

Re: Calling the source command from subprocess.popen to update the os.environ.

2016-03-27 Thread Chris Angelico
On Mon, Mar 28, 2016 at 12:24 AM, Hongyi Zhao wrote: > # replace env > os.environ.clear() > os.environ.update(line.partition('=')[::2] for line in output.split('\0')) > > Traceback (most recent call last): > File "/home/werner/anaconda2/lib/python2.7/site-packages/IPython/core/ > interactiveshel

Re: Calling the source command from subprocess.popen to update the os.environ.

2016-03-27 Thread Oscar Benjamin
On 27 Mar 2016 17:01, "Ben Finney" wrote: > > Hongyi Zhao writes: > > > I use the following code the update the os.environ: > > > > import os > > from subprocess import check_output > > > > # POSIX: name shall not contain '=', value doesn't contain '\0' > > output = check_output("source /home/wer

Re: Calling the source command from subprocess.popen to update the os.environ.

2016-03-27 Thread Ben Finney
Hongyi Zhao writes: > I use the following code the update the os.environ: > > import os > from subprocess import check_output > > # POSIX: name shall not contain '=', value doesn't contain '\0' > output = check_output("source /home/werner/env-intel-toolchains.sh; > env -0", shell=True, e

Calling the source command from subprocess.popen to update the os.environ.

2016-03-27 Thread Hongyi Zhao
Hi all, Based on the methods here: http://stackoverflow.com/questions/7040592/calling-the-source-command- from-subprocess-popen/18897007#comment30954741_12708396 I use the following code the update the os.environ: import os from subprocess import check_output # POSIX: name shall not contain '=