Installing OpenCV on Windows 7 for Python 2.7

Question:

am trying desperately to get OpenCV to work on Windows 7. I download and installed it, and it didn’t work, I got

ImportError: No module named opencv 

when I tried to run one of the samples. I google my problem and got only random solutions that don’t work. Can anybody guide me in installing it, or know where i can get a clear installation guide design for a programming noob.

Asked By: cubearth

||

Answers:

As of OpenCV 2.2.0, the package name for the Python bindings is “cv”.The old bindings named “opencv” are not maintained any longer. You might have to adjust your code. See http://opencv.willowgarage.com/wiki/PythonInterface.

The official OpenCV installer does not install the Python bindings into your Python directory. There should be a Python2.7 directory inside your OpenCV 2.2.0 installation directory. Copy the whole Lib folder from OpenCVPython2.7 to C:Python27 and make sure your OpenCVbin directory is in the Windows DLL search path.

Alternatively use the opencv-python installers at http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv.

Answered By: cgohlke

I have posted an entry to setup OpenCV for Python in Windows:
http://luugiathuy.com/2011/02/setup-opencv-for-python/

Hope it helps.

Answered By: Thuy

I have posted a very simple method to install OpenCV 2.4 for Python in Windows here : Install OpenCV in Windows for Python

It is just as simple as copy and paste. Hope it will be useful for future viewers.

  1. Download Python, Numpy, OpenCV from their official sites.

  2. Extract OpenCV (will be extracted to a folder opencv)

  3. Copy ..opencvbuildpythonx862.7cv2.pyd

  4. Paste it in C:Python27Libsite-packages

  5. Open Python IDLE or terminal, and type

    >>> import cv2
    

If no errors shown, it is OK.

UPDATE (Thanks to dana for this info):

If you are using the VideoCapture feature, you must copy opencv_ffmpeg.dll into your path as well. See: https://stackoverflow.com/a/11703998/1134940

Answered By: Abid Rahman K

One thing that needs to be mentioned. You have to use the x86 version of Python 2.7. OpenCV doesn’t support Python x64. I banged my head on this for a bit until I figured that out.

That said, follow the steps in Abid Rahman K’s answer. And as Antimony said, you’ll need to do a ‘from cv2 import cv’

Answered By: ehambright

Actually you can use x64 and Python 2.7. This is just not delivered in the standard OpenCV installer. If you build the libraries from the source (http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html) or you use the opencv-python from cgohlke’s comment, it works just fine.

Answered By: yanlend

Installing OpenCV on Windows 7 for Python 2.7

Answered By: user5024366

download the opencv 2.2 version from https://sourceforge.net/projects/opencvlibrary/files/opencv-win/

install package.

then Copy cv2.pyd to C:/Python27/lib/site-packeges.

and it should work:

import cv2
Answered By: NINO Cikoo

open command prompt and run the following commands (assuming python 2.7):

cd c:Python27scripts
pip install opencv-python

the above works for me for python 2.7 on windows 10 64 bit

Answered By: Ohad Cohen
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.