Installing OpenCV for Python on Windows Using Anaconda

sajith dilshan
Geek Culture
Published in
3 min readMay 1, 2022
Installing OpenCV for Python on Windows using Anaconda

OpenCV is a cross-platform library for image processing and computer visualization. It can develop real-time computer vision applications. It mainly focuses on image processing, video capture, and analysis including features like face detection and object detection. In this tutorial, we explain how you can use the install OpenCV using Anaconda.

Step 01: Installing Anaconda on Windows

Go to the Anaconda Website and choose the latest Anaconda graphical installer for Windows from Anaconda Website If it’s 64-bit then choose the 64-bit graphical installer or else choose the 32-bit installer. Choose Python 3.7 for working with Python 3. This is the preferred option as python 2.7 is reaching its End-Of-Life by 2020.

https://www.anaconda.com/products/individual

Locate your download and double click it. Launch the graphical installer and we will be prompted to choose for which user to install. you can install it by default settings

Anaconda Installer

Step 02: Installing OpenCV

Launch the Anaconda prompt from the Start menu

launching Anaconda prompt

if you chose “All users” while installing then you have to launch the prompt by Right-clicking and choosing “Run as Administrator” to execute with administrator privileges. This is critical.

To install the OpenCV we need to type the following command at the prompt:

conda install -c conda-forge opencv

important:

internet connection is required to install OpenCV on your computer

installing OpenCV through anaconda prompt.

after type that command, The prompt will show that it is “solving environment”.

solving environment

Once the environment is resolved by conda it will list the packages that will be installed, namely: opencv , libopencv , py-OpenCV.

Enter y to proceed with the installation.

proceed to install by entering y when prompted as shown.

after installing OpenCV you can show the installation successful message in the anaconda prompt

installation is successful.

you can verify if the installation was successful by launching the python interpreter. OpenCV is referred to as cv2 in python. Type at the prompt:

import cv2

if the prompt is displayed then OpenCV then python has successfully imported the OpenCV library. But we should also verify the version of OpenCV so we need to type:

print(cv2.__version__)

verify the version of OpenCV.

as of March 2019 the version displayed is 3.4.1 which is the officially supported version of OpenCV by anaconda environment. If we want to work with a different version then while installing we can specify the version as “opencv=3.4.1” as shown below

conda install -c conda-forge opencv=3.4.1

Similar steps can be followed to install OpenCV on anaconda for MacOS.

Social Media: LinkedIn, Twitter, Instagram, YouTube

--

--

sajith dilshan
Geek Culture

Software Engineer | Technical Writer | Tech Enthusiast