OSError: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 is not a valid Win32 application python python

OSError: [WinError 193] %1 is not a valid Win32 application


The error is pretty clear. The file hello.py is not an executable file. You need to specify the executable:

subprocess.call(['python.exe', 'hello.py', 'htmlfilename.htm'])

You'll need python.exe to be visible on the search path, or you could pass the full path to the executable file that is running the calling script:

import syssubprocess.call([sys.executable, 'hello.py', 'htmlfilename.htm'])


Python installers usually register .py files with the system. If you run the shell explicitly, it works:

import subprocesssubprocess.call(['hello.py', 'htmlfilename.htm'], shell=True)# --- or ----subprocess.call('hello.py htmlfilename.htm', shell=True)

You can check your file associations on the command line with

C:\>assoc .py.py=Python.FileC:\>ftype Python.FilePython.File="C:\Python27\python.exe" "%1" %*


I got the same error while I forgot to use shell=True in the subprocess.call.

subprocess.call('python modify_depth_images.py', shell=True)

Running External Command

To run an external command without interacting with it, such as onewould do with os.system(), Use the call() function.

import subprocessSimple command subprocess.call(['ls', '-1'], shell=True)