Conda install some-package hangs with (Solving environment: failed)

Viewed 18942

I have tried multiple ways but can't conda install packages (in my case, geopandas). I tried geopandas install guide, but get output that the solver runs forever. I tried without creating an environment, after creating a new environment, using defaults channel and using conda-forge channel. None worked.

$ conda create -n top 
$ conda activate top
$ conda config --env --add channels conda-forge
$ conda config --env --set channel_priority strict
$ conda install python=3 geopandas
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.
Collecting package metadata (repodata.json): done
Solving environment: \ 

I don't want to use pip install because it is preferred to use conda install.

Also I tried installing using Anaconda Navigator following this answer, but the progress bar keeps hanging, saying "solving package specifications".

3 Answers

Favor Specifying Constraints at Creation

Iteratively installing packages is a real choking point for Conda. If you know up front that the env will require certain packages, then specify them at creation:

conda create -n top -c conda-forge -c defaults python=3 geopandas

This solves in seconds for me. If you have many packages, then use a YAML.

Use Mamba

Sometimes ad hoc installations are unavoidable. For tough solves (or just generally), try using mamba, a compiled (fast!) drop-in replacement for conda. Mamba will shine where Conda struggles.

# install mamba
conda install -n base conda-forge::mamba

# use mamba
mamba install -n top geopandas

After trying many advice from Conda's GitHub page, I found out that the issue was not being able to find dependencies for the python version I had installed. Creating new environment help but with one more argument for python version.

conda create -n branch-env python=3.7
conda activate branch-env
conda install geopandas

The conda message "Solving environment: failed with initial frozen solve. Retrying with flexible solve." comes from

Conda install some-package hangs with (Solving environment: failed)

The answer above deserves provides one of the best answers that I have seen anywhere to deal with the time-consuming problem of package incompatibilities and waiting endlessly for conda solver sessions to finish.

The key is to learn in advance what packages you will likely need to use, and then specify those packages UP-FRONT when you create your conda environment, but leave the Python 3.x subversion "floating"). Conda will figure out which sub-version of Python 3.x is the latest and most appropriate to solve the dependencies for all other packages in your target environment.

This approach of determining and specifying your required environment "core" packages up front -- then letting conda work out which Python 3.x version -- avoids the problem of downgrading Python (which frequently does not work).

When your new conda solves and builds your new environment, it can be cloned as a template for future similar work.

Related