1

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 Answer 1

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)
Sign up to request clarification or add additional context in comments.

4 Comments

Got this reult running the second one and first one still gives same OSERROR /bin/sh: module: command not found /bin/sh: calibredrv: command not found /bin/sh: module: command not found
This means that your python interpreter can't find the module executable. You can try to use absolute paths, like this: subprocess.call(['/abs/path/to/module','avail','calibre','&','/abs/path/to/module','load','calibre'])
@Enrico That command line is expected to be interpreted by a shell. It wont work as expected when run without a shell. The & and what follows will just be passed as parameters to "module" command in the first case.
can it be done in a way that i write a bunch of commands in a scrpit and then pass that script using subprocess....if yes Could you help in giving syntax for that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.