Installing OpenCV on windows through Anaconda. How to fix ‘Solving environment…’ error message?

The issue popped up while I was trying to install OpenCV on windows by using Anaconda, which is quite easier than any other method to follow.

Sushant Srivastav
3 min readMay 28, 2020

Installing OpenCV:

Launch the Anaconda prompt from the start menu:

captured from the search box

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 quite essential

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

conda install -c conda-forge opencv

Alternatively, way of installing install the OpenCV:

We can alternatively choose to install through anaconda navigator graphical interface. type in “opencvin search packages search bar. choose to install all the listed packages.

captured from Anaconda Navigator

It will list the packages that will be installed, namely: opencv, libopencv, py-opencv. Just select all the three and click on apply which will install the required packages for OpenCV.

The error got while installing OpenCV on Anaconda:

Error when done through the Anaconda prompt windows:

Solving environment: failed with initial frozen solve. Retrying with flexible solve.

captured from the command prompt

Error through the graphical method:

capture from Anaconda Navigator

The screen is stuck on the process of solving package specifications.

Acknowledging the issue:

Here, after doing through a lot of tutorials and guides I figured out that the error is due to the environment that is running in the anaconda currently. So, the possible solution is by creating a separate environment for installing OpenCV.

To install OpenCV in a separate environment, we need to create a new environment( replace “new_name” with any name in the command below, note the symbol “ — ” is a double hyphen, so just copy-paste the following command by editing “new_name” to any name of your preference.)

conda create — name new_nameactivate opencv

After having followed the above steps new environment is created in Anaconda and we can proceed on installing the OpenCV on a new environment.

a new environment named “myenv”

We can run:

conda install -c conda-forge opencv

This code is going to run and install OpenCV but alongside, it shows all the basic packages that are required for a whole new environment to work in a standalone way:

Enter y to proceed with the installation.

The process is completed now. We can verify if the installation was successful by launching the python interpreter. OpenCV is referred to as cv2 in python. Type the following at the prompt:

import cv2
Anaconda Prompt window

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__)
Anaconda Prompt window

as of May 2020, the version displayed is 4.2.0 which is the officially latest 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=4.1.0” as shown below:

conda install -c conda-forge opencv=4.1.0

--

--

Sushant Srivastav
Sushant Srivastav

Written by Sushant Srivastav

Noob Geek, Tech-Savvy, Aviation Enthusiast, Photographer

No responses yet