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

Get notified of the best deals on our WordPress themes.

You May Also Like
Python Print Variable

Python Print Variable

Table of Contents Hide How to use the print() function in Python?How to Print variable in Python?Method 1: Using comma , character to separate the variables in a print statementMethod…
View Post
Typeerror Unhashable Type 'Dict'

TypeError: unhashable type: ‘dict’

Table of Contents Hide TypeError: unhashable type: ‘dict’Solution to TypeError: unhashable type: ‘dict’.By Converting into a tupleBy Adding Dictionary as a value in another dictionary In Python, all the dictionary…
View Post
Graphviz'S Executables Not Found

Graphviz’s executables not found

Table of Contents Hide How to Fix InvocationException: graphviz’s executables not found?On WindowsOn LinuxOn macOS Graphviz is open source graph visualization software that helps represent structural information as diagrams of…
View Post
Numpy.argmax() In Python

numpy.argmax() in Python

Table of Contents Hide SyntaxParametersReturn ValueFinding the maximum element from a matrix with Python numpy.argmax()Using np.unravel_index on argmax outputFinding Maximum Elements along columns using Python numpy.argmax() The numpy.argmax() function returns the indices…
View Post
Python List Index()

Python List index()

Table of Contents Hide Syntax of List index() index() ParametersReturn Value from List index()Example 1: Find the index of the elementExample 2: Index of the Element not Present in the List…
View Post