Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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".

like image 360
SadHak Avatar asked May 21 '20 03:05

SadHak


People also ask

How do you solve solving environment failed with initial frozen solve retrying with flexible solve?

To Solve Solving environment: failed with initial frozen solve. Retrying with flexible solve Error Just create an env and activate that env and then do the install and your error will be solved.

Is Mamba better than conda?

Mamba is definitely faster than Miniconda, but unfortunately it is still quite a wedge to download. Because it depends on Conda, either way of installing it means you end up with both package managers on your system.

Why does conda take so long?

Unlike many package managers, Anaconda's repositories generally don't filter or remove old packages from the index. This allows old environments to be easily recreated. However, it does mean that the index metadata is always growing, and thus conda becomes slower as the number of packages increases.


2 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
like image 145
merv Avatar answered Sep 19 '22 18:09

merv


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
like image 36
SadHak Avatar answered Sep 19 '22 18:09

SadHak