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

The Solving environment: failed with initial frozen solve. retrying with flexible solve occurs if you try to download any package that already exists and it breaks the anaconda environment.

In this tutorial, we will take a look at what is “Solving environment: failed with initial frozen solve. retrying with flexible solve error” and how to resolve this issue.

What is Solving environment: failed with initial frozen solve. retrying with flexible solve?

If we are working on multiple Python projects, the best way to separate concerns of packages or libraries is by creating virtual environments else you will face the below error while installing packages.

(base) [localhost ~]$ conda --version
conda 4.8.2
(base) [localhost ~]$ conda install -c anaconda requests-kerberos
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.

In Python, when you install a package, it might warn that the package already exists, and it will modify the package by upgrading or downgrading to the relevant version.

Some of the packages would be dependent on other packages, and it might do the changes by upgrading or downgrading them.

Hence to effectively manage the dependencies, each project should have its own virtual environment, and inside that, the packages should be installed and maintained to avoid conflicts.

How to fix Solving environment: failed with initial frozen solve. retrying with flexible solve?

There are multiple ways to fix the error. Let us take a look at each of these solutions in detail.

Solution 1: Create a virtual environment using conda

It is recommended and best practice to have virtual environments for each project to effectively manage the dependencies and packages.

Follow the steps to create and activate the virtual environment using conda.

Step 1: Create a virtual environment using conda

conda create --name myenv

Step 2: Activate the virtual environment

conda activate myenv

Once you have activated the virtual environment, you can install packages inside the virtual environment and manage the dependencies.

Solution 2: Set channel_priority to false

Conda channels are the locations where packages are stored. They serve as the base for hosting and managing packages.

Add channel_priority: false to your .condarc file.

 OR

Run the equivalent command:

conda config --set channel_priority false

By setting channel_priority , conda then sorts the packages as follows:

  1. Sorts the package list from highest to lowest version number.
  2. Sorts tied packages from highest to lowest channel priority.
  3. Sorts tied packages from the highest to the lowest build number.

Solution 3: Upgrade conda to the latest version

Another alternative is to upgrade the conda to the latest version by running the below command.

conda update --all --yes

Once the update is finished, you should be able to install the packages successfully.

conda install -c spyder-ide spyder-unittest

Conclusion

If we do not maintain the virtual environments while developing Python projects then you will get  Solving environment: failed with initial frozen solve. retrying with flexible solve error while installing the packages and managing the dependencies.

We can resolve this issue by creating a separate virtual environments for each projects using conda and installing the packages inside the virtual environment.

Leave a Reply

Your email address will not be published.

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like

XOR in Python

XOR Operator in Python is also known as “exclusive or”  that compares two binary numbers bitwise if two bits are identical XOR outputs as 0 and when two bits are different then…
View Post
Numpy Mean

NumPy mean()

Table of Contents Hide NumPy mean() SyntaxNumPy mean() ParametersNumPy mean() Return ValueExample 1: Using the numpy.mean() method on a flattened arrayExample 2: Compute the mean of the array column-wise using…
View Post