Ask Your Question

Revision history [back]

Not a valid Win32 application means that the python shell is running 32 bits, but the opencv package cv2 that it is attempting to import is NOT 32 bits. Opencv only seems to provide an x64 or x86 option; they must not have updated their instructions or links after they updated their code.

To fix this, you need to install the 64 bit version of python, numpy, AND matplotlib. Unfortunately, this is a little trickier than one might expect because pip, the python package manager, is not included on python versions below 2.7.9, and the version OpenCV requires is 2.7.5. The other issue is that pip is meant to be run from a terminal and NOT the python IDLE console, because it is a module -- the console is equipped for running individual lines of python code.

To acquire pip, you need to open a bash terminal. Bash is a system, reminiscent of command line interfaces wherein all programs had to be launched by typing a command (before GUIs came along), that can call other programs. The other problem is that Windows does not natively have Bash.

The solution: First, install the 64 bit version of Python 2.7.5 (MSI). Then install cygwin. Then type the following into the Cygwin terminal: C:/Python27/python.exe -m easy_install pip. This will install pip. Then you can type C:/Python27/python.exe -m pip numpy and C:/Python27/python.exe -m pip matplotlib. Then everything will be installed, and you can continue with the instructions here from step 3.

Not a valid Win32 application means that the python shell is running 32 bits, but the opencv package cv2 that it is attempting to import is NOT 32 bits. Opencv only seems to provide an x64 or x86 option; they must not have updated their instructions or links after they updated their code.

To fix this, you need to install the 64 bit version of python, numpy, AND matplotlib. Unfortunately, this is a little trickier than one might expect because pip, the python package manager, is not included on python versions below 2.7.9, and the version OpenCV requires is 2.7.5. The other issue is that pip is meant to be run from a terminal and NOT the python IDLE console, because it is a module -- the console is equipped mainly for running individual lines of python code.

To acquire pip, you need to open a bash terminal. Bash is a system, reminiscent of command line interfaces wherein all programs had to be launched by typing a command (before GUIs came along), that can call other programs. The other problem is that Windows does not natively have Bash.

The solution: First, install the 64 bit version of Python 2.7.5 (MSI). Then install cygwin. Then type the following into the Cygwin terminal: C:/Python27/python.exe -m easy_install pip. This will install pip. Then you can type C:/Python27/python.exe -m pip numpy and C:/Python27/python.exe -m pip matplotlib. Then everything will be installed, and you can continue with the instructions here from step 3.

3.