Install and configure OpenCV-4.2.0 in Windows 10 — Python (2024)

This post will guide you through all the steps for installing and configuring OpenCV-4.2.0 in Windows 10 (64-bit) for python use inside the Anaconda environment.

  • OpenCV with Anaconda, for Python 3.6.0+ development

I will focus here on OpenCV for python 3.6.0+, my previous post for VC++ integration can be found here.

Note: To follow along with the tutorial, I will assume that you already have Anaconda and Python 3.6.0 installed. If not, please feel free to install these tools before continuing to read further.

The steps for installing OpenCV through Anaconda are pretty easy and straight forward. Don’t forget to add Anaconda to your path, so you can easily access conda command from the prompt.

Step 1: Create a conda virtual environment for OpenCV

  • conda create --name opencv-env python=3.6

opencv-env refers to the virtual environment name, you can name it as you like, but remember to pick a meaningful name.

  • Create a folder for your project where you will put your python scripts.
  • Head to your folder through the command line cd C:\Users\<username>\my_folder, and activate the virtual environment you just created, with the following command:
  • conda activate opencv-env

Note: if you use bash as your default terminal in windows, conda activate opencv-env might not work as expected. The reason for it is that bash is not, by default, properly configured to run anaconda scripts, so you may give it a workaround:

  1. Edit your .bashrc file c:\Users\<username>\.bash_profileadding the following line of code:
Install and configure OpenCV-4.2.0 in Windows 10 — Python (3)

2. Whenever you want to lunch your bash terminal add the following arguments: --login -i , therefore you will lunch your custom bash profile which has been granted access to conda scripts.

Install and configure OpenCV-4.2.0 in Windows 10 — Python (4)

Now your conda environment is activated and perfectly available.

Install and configure OpenCV-4.2.0 in Windows 10 — Python (5)

Step2: Install OpenCV and the required packages

To use OpenCV you have to install some important packages that go alongside:

pip install numpy scipy matplotlib scikit-learn

pip install opencv-contrib-python

pip install dlib

Step3: Test your installation

And you should get the latest OpenCV version available in the python repo.

And that’s all, have fun with OpenCV.

Install and configure OpenCV-4.2.0 in Windows 10 — Python (2024)
Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6108

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.