Installing Python 2.7 with OpenCV on windows for Image Processing

Ankur Kulhari

For Image processing Python with OpenCV library is widely used. OpenCV provides a vast list of Image Processing techniques (like Enhancement, Segmentation, Feature extraction etc.).
Along with “numpy” and “matplot” OpenCV provides easy and strong facilities for image processing.
Follow these steps to install Python and OpenCV:

  1. Download Python 2.7.13 (Freeware) [32 bit/64 bit].
  2. Install Python 2.7.13 on your system with default settings.
  3. Download numpy 1.10 and install it with default setting.
    Open IDLE (Python GUI) from All Programs → Python 2.7 and type “import numpy”. If no error ⇒ installed properly.
  4. Download matplotlib 1.3 and install it.
    In IDLE type “import matplotlib”. If no error ⇒ installed properly.
    Following errors may come:
    dateutil library not found
    python installation for imageprocessing

    Fig1: Matplot requires dateutil library

    Solution: Open cmd (start → type “cmd” enter).
    If you are connected with proxy server:
    SET HTTPS_PROXY=http://domain\<login username_internet>:<password_internet>@<proxy address>:<port number>
    ex. SET HTTPS_PROXY=http://JII12\jonny.pandey:[email protected]:3128
    Pyhton installation

    Fig2: Setting proxy in cmd and installing packages using pip

    Otherwise no need to do this step.
    In cmd type “pip install python-dateutil”.
    Verify the installation by in IDLE type “import matplotlib”. If no error => installed properly.
    If following error appears, set the environment path for python.
    Python installation

    Fig3: Python path is not set in environment variable list

    Similarly install all the required libraries which are missing.
  5. Download OpenCV (Freeware).
  6. Double click to extract it in the folder “C:\python27\opencv\”.
  7. Copy cv2.pyd file from “opencv\build\python\2.7\x86” [for 32 bit] to “c:\Python27\Lib\site-packages\”.
  8. In IDLE type “import cv2”. If no error ⇒ installed properly.

Comments 1

  1. Pingback: Set environment variables in windows - Study Korner

What do you think about the article?

This site uses Akismet to reduce spam. Learn how your comment data is processed.