How to install packages using conda within a singularity container

I have the following definition file which works great until the very end:

Bootstrap: docker
From: ubuntu:20.04

  apt-get -y update
  apt-get -y upgrade
  apt-get -y install default-jre
  apt-get -y --no-install-recommends install wget git zlib1g-dev curl openssh-client tar gzip ca-ce\
rtificates build-essential cmake

  #Install Mamba
  readonly mamba_installer="Mambaforge-$(uname)-$(uname -m).sh"
  readonly mamba_version="4.10.3-4"
  readonly mamba_prefix="/opt/mamba"
  wget "${mamba_version}/${mamba_install\
  bash "${mamba_installer}" -b -p "${mamba_prefix}"
  rm "${mamba_installer}"
  export PATH="/opt/mamba/bin:$PATH"

  mamba config --add channels defaults
  mamba config --add channels conda-forge
  mamba config --add channels bioconda

  mamba create -y -n blee python=3.6 pip
  mamba init
  . /opt/mamba/etc/profile.d/
  . activate blee
  #mamba install --yes -c conda-forge -c bioconda medaka openblas==0.3.3 spoa racon minimap2

But when it comes to the last line, time to install things from the environment it seems like it is using python 3.9 instead of the one it's supposed to: python3.6

What am I missing?


  • Your mamba install command needs a -n flag to include your environment name so it installs the packages accordingly (as in, uses the Python version specified by your create env command).

    Changing your mamba install command to the following should work:

    mamba install -n blee --yes -c conda-forge -c bioconda medaka openblas==0.3.3 spoa racon minimap2