OpenCV Instructions

First, select your platform:


  1. Download and run the Python installer from here.

    Use the default install location (C:\Python27) and install for all users.

    Note: if you are installing on a 64-bit platform, and you already have the 64-bit version of Python 2.7 installed, you should still run the 32-bit installer, but change the install location to something different, like C:\Python27-32bit, in which case you should modify the paths below appropriately.

  2. Download and run the NumPy installer from here. The installer should automatically detect the Python installation you just performed.

  3. Download and run the OpenCV self-extracting archive from here.

    When prompted for a directory to extract to, choose C:\ and continue. This will create a C:\opencv directory on your hard drive.

  4. Using notepad or your favorite text editor, create two files in the directory C:\Python27\Lib\site-packages named cv.pth and cv2.pth. Both files should contain the single line

  5. Using the control panel, edit the system path for all users to add C:\opencv\build\x86\vc10\bin to the list (don't forget to use a semicolon to separate paths).

    While you're at it, you may also want to add C:\Python27 if you want to run Python from the command prompt.

  6. Test the installation by firing up an interactive Python session. If you can type the line

    import cv2

    hit enter, and get no errors, then the installation was successful.

Mac OS X

To perform the installation, you will need to install the XCode developer toolkit and MacPorts, if you don't have them installed already. See downloads and instructions here. Note that installing XCode from your original OS install media—rather than downloading—is by far the fastest way to get it up and running!

Once you get MacPorts installed, open up the Terminal app and type

sudo port selfupdate
sudo port install py27-numpy
sudo port install opencv +python27
sudo port select --set python python27

After the process finishes, you should be ready to go. Because the last step may modify the system path variable, you might not see the changes take effect until you open up a new terminal window.

Ubuntu Linux

Go to this page and follow steps 1.1-1.3. Then, in the terminal, enter

sudo apt-get update
sudo apt-get install libopencv2.3-dev