In this OpenCV tutorial, we learn how to install OpenCV with Anaconda using pip command, and then verify the installation using a simple Python code to read and display an image.

Install OpenCV Python with Anaconda

Anaconda is a good tool for Python application development. If you have anaconda installed, working with OpenCV becomes easier. You may follow: Install Anaconda tutorial if Anaconda is not installed yet.

To install OpenCV Python with Anaconda, use following pip command.

$ pip install opencv-python

Console Output

$ pip install opencv-python
Collecting opencv-python
  Downloading opencv_python- (24.9MB)
    100% |????????????????????????????????| 24.9MB 35kB/s 
Requirement already satisfied: numpy>=1.11.3 in /usr/lib/anaconda3/lib/python3.6/site-packages (from opencv-python)
Installing collected packages: opencv-python
Successfully installed opencv-python-

OpenCV package for Python is successfully installed.

Verify if OpenCV is installed

Following is a simple program to verify the OpenCV Python package. We shall use methods of cv2 to read and display an image.

Python Program

import cv2

img = cv2.imread('/home/img/python.png')


When you run the above example, the following image would be displayed in a separate window.

OpenCV Python Display Image


In this Python OpenCV Tutorial, we learned how to install OpenCV with Anaconda.