I have a Python script that needs to invoke another Python script in the same directory. I did this:
from subprocess import call
call('somescript.py')
I get the following error:
call('somescript.py')
File "/usr/lib/python2.6/subprocess.py", line 480, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.6/subprocess.py", line 633, in __init__
errread, errwrite)
File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I have the script somescript.py in the same folder though. Am I missing something here?
First, check if
somescript.py
is executable and starts with something along the lines of#!/usr/bin/python
. If this is done, then you can usesubprocess.call('./somescript.py')
.Or as another answer points out, you could do
subprocess.call(['python', 'somescript.py'])
.subprocess.call
expects the same arguments assubprocess.Popen
- that is a list of strings (theargv
in C) rather than a single string.It's quite possible that your child process attempted to run "s" with the parameters "o", "m", "e", ...
Check out this.