system cannot find the specified file python subprocess
Question: I am trying to run a simple command in python:

    
    
    from subprocess import *    
    check_output("ls")
    

When I run this it raises

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


Answer: `ls` doesn’t exist on Windows; `dir` does. Furthermore, you may need to pass
`shell=True`, since it’s built in to `cmd.exe`.

If it’s not a test and you just want to get the contents of a directory, use
[`os.listdir`](https://docs.python.org/3/library/os.html#os.listdir) instead.

