Install OpenCV on Windows 7 for Python 2.7

I am desperately trying to get OpenCV to work on Windows 7. I download and install it and it does not 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 do not work. Can anyone advise me to install it or find out where I can get a clear installation guide for noob programming.

+29
python opencv
Jan 17 '11 at 1:30
source share
8 answers

Like OpenCV 2.2.0, the package name for Python bindings is "cv". Old bindings with the name "opencv" are no longer supported. You may need to customize your code. See http://opencv.willowgarage.com/wiki/PythonInterface .

The official OpenCV installer does not install Python bindings in your Python directory. The OpenCV 2.2.0 installation directory must have a Python2.7 directory. Copy the entire Lib folder from OpenCV \ Python2.7 \ to C: \ Python27 \ and make sure your OpenCV \ bin directory is in the Windows DLL search path.

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

+42
Jan 17 '11 at 3:27
source share

I posted a very easy way to install OpenCV 2.4 for Python on Windows: Install OpenCV on Windows for Python

It is as simple as copying and pasting. I hope this will be useful for future viewers.

  • Download Python, Numpy, OpenCV from your official sites.

  • Extract OpenCV (will be extracted to the opencv folder)

  • Copy .. \ opencv \ build \ python \ x86 \ 2.7 \ cv2.pyd

  • Paste it into the folder C: \ Python27 \ Lib \ site-packages

  • Open Python id or terminal and type

     >>> import cv2 

If there were no errors, everything is in order.

UPDATE (thanks dana for this info):

If you use the VideoCapture function, you must copy opencv_ffmpeg.dll to your path. See: stack overflow.squite

+40
Jun 02 2018-12-12T00:
source share

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

Hope this helps.

+5
Feb 27 '11 at 4:25
source share

In fact, you can use x64 and Python 2.7. It just doesn't ship in the standard OpenCV installer. If you create libraries from source ( http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html ), or you use opencv-python from cgohlke comment, it works fine.

+1
Feb 22 '13 at 13:44
source share

One thing to mention. You must use Python version 2.7 for x86. OpenCV does not support Python x64. I hit my head a bit about it until I realized.

However, follow the steps in response of Abid Rahman K. And as Antimony said, you need to make "from cv2 import cv"

0
Nov 02 '12 at 4:16
source share

Install OpenCV on Windows 7 for Python 2.7

0
Jun 18 '15 at 13:51 on
source share

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

install the package.

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

and it should work:

 import cv2 
0
Apr 04 '17 at 22:18
source share

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

 cd c:\Python27\scripts\ pip install opencv-python 

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

0
Nov 26 '17 at 13:34 on
source share



All Articles