1

I am trying to create a conda environment in a Linux cluster using the following command:

conda env create -f env.yml -p ./env

but after "Collecting package metadata (repodata.jason)" is finished, the process is stuck at "solving environment", which has lasted for over 24 h and is still running. I google this problems. Although some people got the same problem and no correct resolution can be found.

I tried to check the .condarc file to modify the channels. Although "conda info" command showed the condarc file existed (/PHShome/ys738/.condarc), it is actually not in that location. Could you tell me why?

The channels shown by "conda info" include:

   https://repo.anaconda.com/pkgs/main/linux-64
   https://repo.anaconda.com/pkgs/main/noarch
   https://repo.anaconda.com/pkgs/r/linux-64
   https://repo.anaconda.com/pkgs/r/noarch

I added two channels (conda-forge, bioconda) by using "conda config --add", but it is still stuck at "solving environment". Do anyone know an effect way to address this issue?

Yeping Sun
  • 405
  • 1
  • 6
  • 18
  • 1
    Because you are not using Mamba ;) - Seriously, though, use Mamba. And don't manually edit `.condarc` files - the `conda config` command can do that. – merv Dec 15 '22 at 19:33
  • 1
    Channel organization can also be a problem, as noted [in this answer](https://stackoverflow.com/a/66963979/570918). – merv Dec 15 '22 at 19:38
  • Installing Mamba by "conda install mamba -n base -c conda-forge" is also stuck at "solving environment" :((( – Yeping Sun Dec 15 '22 at 22:29
  • 1
    Is this an Anaconda **base**? It's situations like this that users realize they should not be using the **base** environment for work (which is something Anaconda implicitly encourages). You could try temporarily using [Micromamba](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html) to handle the Mamba installation to **base** (just be sure to point the `--root-prefix` to your **base** directory). – merv Dec 16 '22 at 02:23
  • Yes, it's an Anaconda base. But how to use Micromamba to handle the Mamba installation to base? I tried "micromamba install -c conda-forge mamba --root-prefix=/PHShome/ys738/software/anaconda/install", but it gives "libmamba No target prefix specified" error. – Yeping Sun Dec 16 '22 at 19:14
  • 1
    add a `-n base` – merv Dec 16 '22 at 19:16
  • mamba installed, but when creating the environment by "mamba create --file env.yml -p ./env", it gives "CondaValueError: could not parse 'name: sc-tutorial' in env.yml". After commenting out the line 'name: sc-tutorial' in the yml file, it gives "CondaValueError: could not parse '- conda-forge' in env.yml". – Yeping Sun Dec 16 '22 at 20:55
  • 1
    The correct command should be: "mamba env create --file env.yml -p .“ – Yeping Sun Dec 16 '22 at 21:10

1 Answers1

2

The steps to solve this problem are

(1) install micromamba

wget https://micromamba.snakepit.net/api/micromamba/linux-64/latest -O micromamba.tar.bz
tar -xf micromamba.tar.bz2

Then add micromamba excutable in the bin directory to $PATH

(2) install mamba

micromamba install -c conda-forge mamba --root-prefix=/path/to/anaconda/base -n base

(3) Create the environment

mamba env create --file env.yml -p ./env

Yeping Sun
  • 405
  • 1
  • 6
  • 18
  • 1
    I would note that the `--prefix,-p` flag is not necessary - just something you preferred to do. Most users refer prefer the `--name,-n` flag so that environments install the to default `envs_dirs` location and can be activate by name. – merv Dec 16 '22 at 21:44
  • Must the -name value be the same with the "name:" line in the yml file? Will the name of the created environment the same the with --name value or the value in the "name:" line in the yml file? – Yeping Sun Dec 16 '22 at 21:56
  • 1
    No, it doesn't matter. The command arguments *override* the values in the YAML. So, if you use `-n foo` in the command, the value in the YAML will be ignored. The YAML value for `name: ` will only be used if you do not provide an `-n` nor `-p` argument. – merv Dec 16 '22 at 22:19