I want to run a pw.x in bash with this command: mpirun -np 4 pw.x < input.in through a python script. I used this:
from subprocess import Popen, PIPE
process = Popen( "mpirun -np 4 pw.x", shell=False, universal_newlines=True,
stdin=PIPE, stdout=PIPE, stderr=PIPE )
output, error = process.communicate();
print (output);
but it gives me this error:
Original exception was:
Traceback (most recent call last):
File "test.py", line 6, in <module>
stdin=PIPE, stdout=PIPE, stderr=PIPE )
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'mpirun -np 4 pw.x': 'mpirun -np 4 pw.x'
How can I use "mpirun -np ..." in python scripts?