ImportError: DLL load failed: %1 is not a valid Win32 application


Question

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 win7 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 in the Lib/site-packages folder of python.

Unfortunately the suggestion of using the 32 bits version of python isn't working for me anymore as I have to handle numpy arrays too large for 32 bits.

Thanks!!!

------ UPDATE

The only thing missing was to add the new opencv binaries path (C:\opencv\build\bin\Release) to the Windows PATH environment variable, restart python.

Everything seems to be working fine now!

1
31
1/31/2013 4:16:21 PM

Accepted Answer

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).

24
7/23/2013 9:06:49 PM

You could try installing the 32 bit version of opencv


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon