I am trying to execute a Python script from within my Django app. I tried executing it from the terminal and it works correctly, so I know the called Python script is working fine. The Python scripts calls an external program which overwrites a file on the server. The external program has all required permissions. I even tried using 777 permissions for all files involved, but still no use.
Django View:
import subprocess
subprocess.call("python " + script_dir+"testScript.py", shell=True)
Python - 2.7
I can execute simpler commands like
subprocess.call("rm " + script_dir+"test.txt", shell=True)
EDIT: I am not only executing python scripts from the terminal, I also need to execute a blender script, which again works fine by itself(when executed directly from the terminal) but does not generate the required output from within django.
This was the error as in my Django console :
OSError at /getObj/
[Errno 2] No such file or directory
Request Method: GET
Request URL: http://192.168.1.21:8081/getObj/?width=5.0&height=6.0&depth=7.0
Django Version: 1.7.8
Exception Type: OSError
Exception Value:
[Errno 2] No such file or directory
Exception Location: /usr/lib/python2.7/subprocess.py in _execute_child, line 1327
Python Executable: /usr/bin/python
Python Version: 2.7.6
subprocess? Why not import it and call it directly?script_dir+"testScript.py"Make sure it's absolute