I have this issue where I try to import cv2
on Python and get the following error message.
>>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed: %1 is not a valid Win32 application.
I do understand there are many posts about this where it is suggested that the bitness of the package is different from the Python package.
However, everything I am running is 64 bits. I am on Windows 7 64 bits, I have the winpython 2.7.3.3, 64 bits distribution, and I compiled OpenCV in 64 bits with the instruction provided here and placed the cv2.pyd DLL file in the Lib/site-packages folder of the Python interpreter.
Unfortunately, the suggestion of using the 32 bits version of Python isn't working for me any more as I have to handle NumPy arrays too large for 32 bits.
The only thing missing was to add the new NumPy binaries path (C:\opencv\build\bin\Release) to the Windows PATH environment variable, restart the Python interpreter.
Everything seems to be working fine now!
In most cases, the “1 is not a valid Win32 application” occurs due to the incompatibility between the Windows version/type and program. Please make sure you have downloaded the right version of the installer file. Press Windows key + R to call out the Run box.
Method 1. Download the Installer File Compatible with the System In most cases, the “1 is not a valid Win32 application” occurs due to the incompatibility between the Windows version/type and program. Please make sure you have downloaded the right version of the installer file. Press Windows key + R to call out the Run box.
[Error 193] %1 is not a valid Win32 application. DLL load failed: %1 is not a valid Win32 application. The specific error message may vary depending on what program you are opening or running, but there must be “%1 is not a valid Win32 application” in the error message. Why does the error occur? The possible reasons are as follows:
python - ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there - Stack Overflow ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there
If your build system ( CMake in my case) copies the file from <name>.dll to <name>.pyd, you will get this error if the original file wasn't actually a DLL file. In my case, building shared libraries got switched off, so the underlying file was actually a *.lib.
The ImportError message is a bit misleading because of the reference to Win32, whereas the problem was simply the OpenCV DLLs were not found.
This problem was solved by adding the path the OpenCV binaries to the Windows PATH environment variable (as an example, on my computer this path is: C:\opencv\build\bin\Release).
You could try installing the 32 bit version of OpenCV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With