Oserror: [winerror 193] %1 Is Not A Valid Win32 Application
Solution 1:
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 sys
subprocess.call([sys.executable, 'hello.py', 'htmlfilename.htm'])
Solution 2:
Python installers usually register .py files with the system. If you run the shell explicitly, it works:
import subprocess
subprocess.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.File
C:\>ftype Python.File
Python.File="C:\Python27\python.exe""%1" %*
Solution 3:
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)
To run an external command without interacting with it, such as one would do with
os.system()
, Use thecall()
function.
import subprocess Simple command subprocess.call(['ls', '-1'], shell=True)
Solution 4:
All above solution are logical and I think covers the root cause, but for me, none of the above worked. Hence putting it here as may be helpful for others.
My
environment
was messed up. As you can see from the traceback, there are two python environments involved here:
C:\Users\example\AppData\Roaming\Python\Python37
C:\Users\example\Anaconda3
I cleaned up the path and just deleted all the files from C:\Users\example\AppData\Roaming\Python\Python37
.
Then it worked like the charm.
This link helped me to found the solution.
Solution 5:
I got this error while trying to install SpaCy. I had Python 3.7 32-bit version, which didn't let me install SpaCy.
First, I tried to upgrade to Python 3.9 64-bit version and uninstalled python 3.7. Then to save my libraries I copied the site-packages of the python 3.7 version to the 3.9 version, which gave me this error while downloading SpaCy.
While there were a lot of errors in the lib folder, but I solved [OSError: WinError 193] by uninstalling NumPy and then re-installing it.
Post a Comment for "Oserror: [winerror 193] %1 Is Not A Valid Win32 Application"