Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106339

Failed to update the os.environ with subprocess.Popen.

From Hongyi Zhao <hongyi.zhao@gmail.com>
Newsgroups comp.lang.python
Subject Failed to update the os.environ with subprocess.Popen.
Date 2016-04-03 03:28 +0000
Organization NPO RUSnet InterNetNews site
Message-ID <ndq2ll$h79$1@aspen.stu.neva.ru> (permalink)

Show all headers | View raw


Hi all,

I use the following code to update the os.environ with subprocess.Popen:

-------------
from subprocess import Popen

output = Popen("""
/bin/bash <<EOF
source ~/.profile.d/modules/modules.sh
export PATH=$MODULESHOME/../default/bin:$PATH
module add intel/parallel_studio_xe_2015
env -0
EOF
""", shell=True)

if "" in os.environ.data: del os.environ.data[""]
os.environ.clear()
os.environ.update(line.partition('=')[::2] for line in output.split('\0'))
-------------

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 <module>
    os.environ.update(line.partition('=')[::2] for line in output.split
('\0'))
AttributeError: 'Popen' object has no attribute 'split'
-------------------

How to solve this issue?
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Failed to update the os.environ with subprocess.Popen. Hongyi Zhao <hongyi.zhao@gmail.com> - 2016-04-03 03:28 +0000

csiph-web