0

I have seen :ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there

And a couple of other solutions that suggest placing the \opencv\build\python\2.7\x86\cv2.pyd to my Anaconda virtual environment's \Lib\site-packages, I am working with Anaconda3 and in my environment I have Python version as below:

Python 2.7.15 |Anaconda, Inc.| (default, May  1 2018, 18:37:12) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Strangely, despite replacing the file at every possible location of Python in my Windows 10 system, I fail to run the script which uses import to opnecv.

Matěj Štágl
  • 870
  • 1
  • 9
  • 27
user2176576
  • 734
  • 3
  • 14
  • 39

1 Answers1

0

You're using the 32 bit version of Anaconda as we can see from the Python output. Then you have downloaded the 64 bit version of OpenCV according your comment.

You can't mix 32 bit and 64 bit applications. It's not possible in Windows in general, neither in Python, nor in C#, nor in C++ or any other programming language.

So you have 2 options now:

  • get a 64 bit version of Python that works with your OpenCV. E.g. on the Anaconda download site look for a win-64 version. Your output should then look like

    Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32
    

    Note that the on win32 at the end is a bit confusing and just means "on the Windows platform"

  • get a 32 bit version of OpenCV that works with your Python

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222