I have a command to run from python program
python test.py arg1 arg2
If I run it using
os.system("python test.py arg1 arg2")
it runs.
I want to use subprocess.Popen() but when I do that
subprocess.Popen("python test.py arg1 arg2")
It gives the following error
raise child_exception
OSError: [Errno 2] No such file or directory
Any ideas?
Thanks a lot
If argument to
Popenis a string, it tries to execute it as'sh <argument>', so in your case it becomes'sh python test.py arg1 arg2'that is obviously wrong. You can pass it a list (as twall suggested), or specifyshell=Trueparameter. The next should work: