Overview

Miniconda is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. It can also be used to start with a minimal set of installed packages, and then install only the required ones (to save space).

Using

Use the module name miniconda3 to discover versions available and to load the application.

When using miniconda3 via an interactive session (salloc) or submitting a script via sbatch, please make sure to explicitly load the miniconda3 module once you have your interactive session on the compute node, and within you bash script.

If you do not, you’ll see an error of the form: CondaError: Run 'conda init' before ...

Training:

ARCC’s training pages are currently under review/revision.

Install Packages into a Miniconda Environment in Your Home Directory

The following commands are useful for creating and using environments in your home directory:

conda info --envs

show environments

conda create -n NAME

create an environment named NAME in your home related conda location.

conda create -n NAME python=3.4

create an environment named NAME, with specified Python version

conda create -p NAME

create an environment named NAME in your current location.

conda activate NAME

activate environment NAME

conda install PKG

install package PKG into the current environment

conda install -c CHANNEL PKG

install package PKG from channel CHANNEL into the current environment

conda list

show packages in current environment

conda list -n NAME

show packages in environment NAME

conda deactivate

deactivate current environment

Installing Python Packages

After creating and activating an environment, packages available through Anaconda can be installed into that environment using the conda install command. For example, NumPy can be installed by:

conda install numpy

There are also packages available through different channels. For example, PyNIO and PyNGL from NCAR are available through the conda-forge channel, and can be installed by:

conda install -c conda-forge pynio
conda install -c conda-forge pyngl

Searching for Packages in Channels

To search if a package is available in the current channels, e.g. the package demultiplex:

conda search demultiplex

To search if a package is available from a particular channel (the conda-forge channel in this example):

conda search -c conda-forge demultiplex

If a package isn't available from a conda channel but is available as a PyPi package (usually installed with pip), it can still be installed into a conda environment.

Examples

Example: Installing a conda Package

Using the above commands, here is an example of creating an environment and installing the NumPyPyNIO and PyNGL packages into it:

  1. Load Miniconda (and dependecies):

    module load miniconda3/<version> 
  2. Create and activate the environment:

    conda create -n hdf python=2.7
    conda activate hdf 
  3. Install the packages:

    conda install numpy
    conda install -c conda-forge pynio
    conda install -c conda-forge pyngl
  4. Deactivate environment:

    conda deactivate

It is also possible to interactively search/browse conda packages on the Anaconda Cloud site.

Example: Installing a PyPi Package

Using the above commands, here is an example of creating an environment and installing the PyPi demultiplex package into it:

  1. Load Miniconda (and dependencies):

    module load miniconda3/<version>
  2. Create and activate the environment:

    conda create -n demux
    conda activate demux
  3. Install pip into this environment:

    conda install pip
  4. Update pip (in the conda environment):

    pip install --upgrade pip
  5. Use pip (from the conda environment) to install the demultiplex package:

    pip install demultiplex
  6. Deactivate environment:

    conda deactivate

Using Installed Python Packages

There are two ways to use Python packages installed in conda environments. For example, to use the demultiplex package installed above:

#!/home/uname/.conda/envs/demux/bin/python

where uname is replaced with your username, and demux is replaced by the name of your environment.

Example: Installing a C/C++ Package

Besides Python packages, conda can be used to install packages for various other languages such as R, C, and C++. For example, the GNU Scientific Library (GSL) is a numerical library of various mathematical functions that can be used in C and C++ programs. It is available as a conda package and can be installed by:

  1. Load Miniconda (and dependecies):

    module load miniconda3/<version>
  2. Create and activate the environment:

    conda create -n gsl
    conda activate gsl
  3. Install the packages:

    conda install gsl
  4. Deactivate environment:

    conda deactivate

After installing gsl into a conda environment as above, it is possible to use it in a C or C++ program by adding the necessary include and/or library paths to the paths that will be searched, e.g.:

Note that the include and library paths will be different for different packages, and can be found by (from home directory) 'cd .conda/envs/NAME' where NAME is the name of the environment that the package was installed into, and then looking to see where the different types of files are.

Troubleshooting and Other Notes

Common Error Messages

Error: /lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b

This error is typically associated when trying to use git after performing a module load miniconda3/<version>. For example:

[jcook27@wilog01 multiqc]$ git clone https://github.com/ewels/MultiQC_TestData
Cloning into 'MultiQC_TestData'...
/usr/libexec/git-core/git-remote-https: symbol lookup error: /lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b

This is a know system issue as suggested here https://bugzilla.redhat.com/show_bug.cgi?id=1829790 and relates to trying to use a newer version of openssl than installed on the base system.

There are a number of potentially solutions depending on what your use case is:

  1. Use a newer version of git than provided by the base system. Perform a module spider git to see available versions and load.

  2. If you’re using an active conda environment, then you can explicitly install conda into it via conda install -c anaconda git.

Error: json.decoder.JSONDecodeError: Expecting value: line

This may occur while trying to install packages, or creating a new environment.
Solution: Try conda clean -i in your account then re-perform the conda install step.
The clean command removes unused packages and caches, with the -i option removing the index cache that might have become corrupted..

Further Information