4

Python 2.7 - crashing on subprocess.py - Windows Error: [Error 2] The system cannot find file

File "C:\Python27\lib\subprocess.py", line 709, in __init__ errread, errwrite) File "C:\Python27\lib\subprocess.py", line 957, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified 

I have searched the rest of the questions and tried all the path settings and environmental variables and all that seems fine.

Thanks for your help in advance.

1
  • 1
    What command did you invoke? Or what python code caused the error? Commented Dec 5, 2013 at 9:07

2 Answers 2

0

"WindowsError: [Error 2] The system cannot find the file specified"

I had the same error when I want to envoke a programm which isn't installed (I use ubuntu instead of windows).

http://docs.python.org/2/library/subprocess.html#exceptions

try to excute the command manually in the shell , to get the real error

or use this fine method :

from subprocess import CalledProcessError, check_output try: output = check_output(["ls", "non existent"]) except CalledProcessError as e: print(e.returncode) 

N.B: in my system (ubuntu) , I get :

ls: cannot access non existent: No such file or directory 2

In windows there is no "ls" command , you will get exception meaning that.

from : Check a command's return code when subprocess raises a CalledProcessError exception

check this : Using subprocess to run Python script on Windows

Sign up to request clarification or add additional context in comments.

Comments

0

Use list while running command via subproccess. list should be created by follows: Suppose you want ot run command :

ls -l 

Then command should be

cmd = ["ls" "-l" ] subprocess.Popen(cmd) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.