[Linux/Ubuntu] How to fix ‘Solving environment: failed with initial frozen solve. Retrying with flexible solve’ in Anaconda without creating a new environment

Amritya Singh
Floppy Disk F
Published in
3 min readFeb 13, 2021

--

So if you’re new to Anaconda or have just encountered the ‘Solving environment: failed with initial frozen solve. Retrying with flexible solve’ while installing a certain package in your environment, then here’s the fix without creating a new environment!

Please got through it carefully!

What to avoid?

Many of the fixes that you’ll find online will tell you to create a new environment altogether and then install the package that you are having trouble with in that environment.

Creating a new environment by running:

conda create --name env1

And then activating it by:

conda activate env1

And then installing the package (let’s assume it’s opencv) in the new environment (env1) by running:

conda install opencv

Now, we should avoid creating a new environment altogether because it’s just a time consuming temporary get-around, and we might face the same problem in the future because the real issue hasn’t been dealt with. Also, creating a new environment every time you come across this error is just lame. So, I’d suggest not following through this step.

The root of the problem?

So, let’s say you decide to install opencv in your environment (my_env in my savedcase). So you activate your environment:

conda activate my_env   #replace 'my_env' with your environment name

And then install the opencv package:

conda install opencv

And come across this error:

Solving environment error

Now, this happened because there is a conflict with the existing packages and the package we are trying to install. We can see, that that opencv isn’t compatible with python=3.8, which is our anaconda’s python version. The rest of the packages which are already installed works on the version 3.8 but opencv doesn’t.

We can clearly see in the error output message that the which python versions work with opencv.

The fix?

What we need to do is simply change the python version inside anaconda. We can first see the list of the python versions inside of anaconda by executing:

conda search python 

We’ll get something like this:

python version list

Now, we know that any python version between 2.7 and 3.8 is supported by opencv. So select any version between that bracket, preferably the latest one, in my case I am chosing 3.7.5 and install it in our environment by executing:

conda install python=3.7.5

Now, after executing this command, the python version will shift to 3.7.5 and all the packages will be updated/downgraded to that version.

Now we will install opencv in our environment by:

conda install opencv

And voila! It’s installed!

Successfully installed

You can install any other packages the same way if you’re having a similar problem with your anaconda environment.

Leave a clap, if it helped you!

--

--