Image Processing Series#1 : Getting Started with OpenCv for Python Or Set Up OpenCV for Python

To run OpenCv with the Python following are the prerequisite to be installed on your system :

  • Python
  • Numpy (A python library)
  • Matplotlib ( A Python Library )

Below are the steps to install the above prerequisite :

  1. Python – You need to Install Python only if you already don’t have Python Installed in your system. The Easy and the simplest way to install python is through Anaconda Distribution . If you are a new user to Python and want to know how to install Python via the Anaconda Distribution , You can go through the step by step Blog i have written to install Python via Anaconda Distribution & start using Jupyter Notebook :

If you would like to Install Python through WinPython , The below shows the step by step method . Please note You can install python either of the two ways i.e Through Anaconda Distribution explained in the Blog Link above or WinPython as explained below. Both WinPython and Anaconda are very popular Python Distribution having some advantage here & there and your choice depends which one is being used in your Company & your Technical Lead Project Preference . If you are starting scratch and learning for yourself you can Install through Anaconda and skip the below section. 

For WinPython Installation : Below is the link to download :

Click on the green download button to start downloading. Once the download is completed open the open setup file downloaded upon which following screen will be displayed : –

By Accepting the agreement click on the Next to get the below screen :

Once all the files are extracted on the desired folder you are ready to use python with all the basic and common libraries ready to get imported in your python code.

The extracted files inside the folder specified looks like as below:

From the above list you can use either Spyder or Jupyter Notebook for your development purpose.

The above steps would extract the Python but to install a library for instance OpenCV would require a system path to be set for Python and and python package installing library easy_install.

Below are steps to be following steps for the same :

RIght Click either “This PC” or “My Computer” icon as per your Operating system version. Then click on “Advanced System Settings” on Upper left corner :

After clicking this following screen will be displayed :

Now click on environment variables button as indicated above.

On the upper area of the resultant screen click on the system variable path and then click edit.

Add the below paths where the python installed files are being extracted to the paths :



Note : – In windows 10 you have to append it in the list of paths and in previous versions these path needs to be appended in the single string with “;” as a separator.

Once this this done click on “OK”

To test if everything is OK, open command prompt or CMD form the windows and type python if python shell is opened as below then everything went fine :

Now the next steps is to configure OpenCV library for python.

Now from the command prompt type in the below command :

easy_install opencv_python

This command would install Opencv library for Python as below :

Once this done to test if everything is done successfully again from the command prompt open python and type “import cv2”. If the package is imported without any error as below, then you are done with configuring OpenCV for Python and start using this image processing library to write the python code.

Now you are all set to write cool stuff to process image and videos !