I have some custom commands.
This works:
subprocess.Popen(['python'], stdout=subprocess.PIPE) But if I have my own system commands like deactivate, I get that error
Traceback (most recent call last): File "runner2.py", line 21, in <module> main() File "runner2.py", line 18, in main subprocess.Popen(['deactivate',], stdout=subprocess.PIPE) 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 Let alone I need to execute this under my sandbox virtualenv.
pythonis not on thePATHenvironment variable when your script runs. Try setting the full path to python, i.e./usr/bin/python.subprocesshasn't "sourced" the virtualenv activation script, and it's not inherited from the parent Python process (assuming that's where you're running it from).