4

I notice if I am trying to remove huge conda packages that occupy hundreds of megabytes in space, running conda remove <package> will take forever. Some examples of these huge packages are pystan, spacy-model-en_core_web_lg.

It is stuck at with no error messages;

Collecting package metadata (repodata.json): done

Solving environment:

Any hints how to fix this problem?

I am using anaconda, python 3.8, windows 10.

user3848207
  • 3,737
  • 17
  • 59
  • 104

1 Answers1

15

Conda's remove operation still needs to satisfy all the other specifications for the environment, so Conda invokes its solver and this can be complicated. Essentially, it re-solves the entire environment sans the specified package, compares that against the existing state, then makes a plan based on the difference.

I very much doubt there is anything directly impactful about size of package, which OP alludes to. Instead, things that negatively impact solving are:

  • having a large environment (e.g., anaconda package is installed)
  • channel mixing - in particular, including the conda-forge channel at equal or higher priority as defaults in an environment with the anaconda package; that package and all its dependencies are intended to be sourced from the anaconda channel
  • having an underspecified environment (see conda env export --from-history to see your explicit specifications); e.g., an environment with a python=3.8 specification will be easier on the solver than just a python specification

In general, using smaller specialized (e.g., per-project) environments, rather than large monolithic ones helps avoid such problems. The anaconda package is particularly problematic.

Try Mamba

Other than adopting better practices, one can also get significantly faster solves with Mamba, a drop-in compiled replacement for conda. Try it out:

## install Mamba in base env
conda install -n base conda-forge::mamba

## use it like you would the 'conda' command
mamba remove -n foo bar
merv
  • 67,214
  • 13
  • 180
  • 245