How to run command module avail using subprocess?

2019-08-06 19:14发布

问题:

I want to call module avail and module laod during my python code using subprocess.call which is something like this.

    subprocess.call(['module avail calibre','&','module load calibre'])

But when I run this code it returns:

OSERROR (2, 'No such file or directory')

Any help regarding subprocess??

回答1:

If you are trying to run this shell command:

$ module avail calibre & module load calibre

with subprocess try:

subprocess.call(['module','avail','calibre','&','module','load','calibre'])

or:

subprocess.call('module avail calibre & module load calibre',shell=True)