0

I try to do this by using subprocess in a views.py

returnCode = subprocess.call('/Users/ivanlw/Projects/C/app') #use the absolute path
print 'returnCode', returnCode

the app file just prints a sentence, it's normal when I execute it in the terminal

but finally the debug page of django tells me OSError, the Exception Value shows: [Errno 2] No such file or directory

How to solve it?

Wei Lin
  • 749
  • 2
  • 6
  • 9

1 Answers1

0

You could try this:

a) check the answer to this question. It shows how to start a subprocess which runs in the background.

p = subprocess.Popen([sys.executable, '/path/to/script.py'], 
                                    stdout=subprocess.PIPE, 
                                    stderr=subprocess.STDOUT)

b) As the error code states the process does not find the file you want to call. If the path is correct maybe change the permissions on the app file.

c) Try to start the subprocess via the shell to see whether it also fails from there:

#start the python shell
python
#call the subprocess
subprocess.call('/Users/ivanlw/Projects/C/app')
Community
  • 1
  • 1
Thomas Kremmel
  • 14,575
  • 26
  • 108
  • 177