How To Install OpenCV For Python On Windows?

OpenCV is an advanced library used for computer vision. OpenCV is an open-source and cross-platform library provided for the Windows and Linux operating systems. By using OpenCV different objects, faces, plates, humans, cars, etc. can be detected in images, videos, and streams easily. OpenCV can be installed in different ways for Windows and Linux operating systems. In this tutorial, we examine how to install OpenCV for Windows from scratch.

Install OpenCV for Windows

As OpenCV is a Python module we should first install Python and its official package manager pip. For the recent versions of Python, the pip is installed automatically which means installing Python is enough for the first step. Use the following URL to download and install Python for Windows operating system.

The installation process shows a screen like below.

After the installation is completed open the MS-DOS or PowerShell command line interface and type the following command in order to check if the pip is installed properly.

PS> pip

If the pip is installed properly we can see the following output which lists the pip commands and options.

OpenCV is a very active project which is updated regularly with new versions. We can show OpenCV-related information with the following command. This displays version, summary, homepage, etc. information.

PS> pip show opencv-python

The OpenCV package is named as opencv-python in the pip repository and we can install OpenCV using pip command like below.

PS> pip install opencv-python

The OpenCV is installed successfully now we can import the OpenCV module cv2 in Python like below and use it.

import cv2


Leave a Comment