There are lots of parameters depends on this error mainly it causes if you have not to install OpenCV installed, So please install the OpenCV application in
C:\lib\opencv on this 64-bit machine. I’m using 64-bit Python. In this article show you how to fix Importerror: dll load failed: %1 is not a valid win32 application
After installation completed check the Python variable
PYTHONPATH=C:\lib\opencv\build\python\2.7. This folder contains
cv2.pyd and that’s all.
My PATH variable:
Path=%OPENCV_DIR%\bin;... This folder contains 39 DLL files such as
OPENCV_DIR has this value:
How to Fix Importerror: dll load failed: %1 is not a valid win32 application
The solution is that at ImportError: DLL load failed: %1 is not a valid Win32 application says to add “the new opencv binaries path (
C:\opencv\build\bin\Release) to the Windows PATH environment variable”. But as shown above, I already have the OpenCV binaries folder (
C:\lib\opencv\build\x64\vc11\bin) in my PATH. And my OpenCV installation doesn’t have any Release folders (except for an empty one under build/java).
Or you can download unofficial binaries for Python Extension package
Check This Before You Begin
Please check if the python version you are using is also 64 bit. If not then that could be the issue. You would be using a 32-bit Python version and would have installed 64-bit binaries for the OpenCV library.
You can found yet another case for this problem. None of the above worked. Eventually, I used python’s ability to introspect what was being loaded. For python 2.7 this means:
import imp imp.find_module("cv2")
This turned up a completely unexpected “cv2.pyd” file in an Anaconda DLL directory that wasn’t touched by multiple uninstall/install attempts. Python was looking there first and not finding my good installation. I deleted that cv2.pyd file and tried imp.find_module(“cv2”) again and python immediately found the right file and cv2 started working.
So if none of the other solutions work for you, make sure you use python introspection to see what file python is trying to load.
Leave a Comment
You must be logged in to post a comment.