Sri Sri - 1 year ago 112
Python Question

Windows can't find the file on

I am getting the following error:

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

My code is:["<<executable file found in PATH>>"])

Windows 7, 64 bit. Python 3.x latest, stable.

Any ideas?


Answer Source

I am not sure why but, on my windows machine I had to add a 'shell=True' to the call.

E.g. for dir you would type:

import subprocess'dir', shell=True)

Hope this helps,


To quote from the documentation: The only time you need to specify shell=True on Windows is when the command you wish to execute is built into the shell (e.g. dir or copy). You do not need shell=True to run a batch file or console-based executable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download