from Anaconda, Inc
is a completely free enterprise-ready distribution for large-scale data
processing, predictive analytics, and scientific computing. It includes
over 195 of the most popular Python packages for science, math,
engineering, and data analysis. It also offers the ability to easily
create custom environments by mixing and matching different versions
of Python and/or R and other packages into isolated environments that
individual users are free to create. Anaconda includes the
package and environment manager to make managing these environments
While the standard methods of installing packages via
easy_install work with Anaconda, the preferred method is using
Full documentation on using Conda is available at http://conda.pydata.org/docs/
A cheatsheet is also provided.
A few examples of the basic commands are provided here. For a full explanation of all of Anaconda/Conda’s capabilities, see the documentation linked above.
Anaconda is provided through the
anaconda module on HCC machines. To
begin using it, load the Anaconda module.
module load anaconda
To display general information about Conda/Anaconda, use the
Conda allows the easy creation of isolated, custom environments with
packages and versions of your choosing. To show all currently available
environments, and which is active, use the
info subcommand with the
conda info -e
The active environment will be marked with an asterisk (*) character.
list command will show all packages installed
in the currently active environment.
To find the names of packages, use the
conda search numpy
If the package is available, this will also display available package versions and compatible Python versions the package may be installed under.
create command is used to create a new environment. It requires
at a minimum a name for the environment, and at least one package to
install. For example, suppose we wish to create a new environment, and
need version 1.8 of NumPy.
conda create -n mynumpy numpy=1.8
This will create a new environment called ‘mynumpy’ and installed NumPy version 1.8, along with any required dependencies.
To use the environment, we must first activate it.
source activate mynumpy
Our new environment is now active, and we can use it. The shell prompt will change to indicate this as well (this can be disable if desired).
To install additional packages in an environment, use the
subcommand. Suppose we want to install iPython in our ‘mynumpy’
environment. While the environment is active, use
install with no
conda install ipython
If you aren’t currently in the environment you wish to install the
package in, add the
-n option to specify the name.
conda install -n mynumpy ipython
remove subcommand to uninstall a package functions similarly.
conda remove ipython
conda remove -n mynumpy ipython
To exit an environment, we deactivate it.
Finally, to completely remove an environment, add the
conda remove -n mynumpy --all
It is not difficult to make an Anaconda environment available to a
Jupyter Notebook. To do so, follow the steps below, replacing
myenv with the name of the Python or R environment you wish to use:
Stop any running Jupyter Notebooks and ensure you are logged out of the JupyterHub instance at https://crane.unl.edu
Using the command-line environment, load the target conda environment:
source activate myenv
Install the Jupyter kernel and add the environment:
For a Python conda environment, install the IPykernel package, and then the kernel specification:
# Install ipykernel conda install ipykernel # Install the kernel specification python -m ipykernel install --user --name "$CONDA_DEFAULT_ENV" --display-name "Python ($CONDA_DEFAULT_ENV)"
For an R conda environment, install the jupyter_client and IRkernel packages, and then the kernel specification:
# Install PNG support for R, the R kernel for Jupyter, and the Jupyter client conda install r-png conda install r-irkernel jupyter_client # Install jupyter_client 5.2.3 from anaconda channel for bug workaround conda install -c anaconda jupyter_client # Install the kernel specification R -e "IRkernel::installspec(name = '$CONDA_DEFAULT_ENV', displayname = 'R ($CONDA_DEFAULT_ENV)', user = TRUE)"
Once you have the environment set up, deactivate it:
To make your conda environments accessible from the worker nodes, enter the following commands:
mkdir -p $WORK/.jupyter mv ~/.local/share/jupyter/kernels $WORK/.jupyter ln -s $WORK/.jupyter/kernels ~/.local/share/jupyter/kernels
Note: Step 5 only needs to be done once. Any future created environments will automatically be accessible from SLURM notebooks once this is done.
Login to JupyterHub at https://crane.unl.edu
and create a new notebook using the environment by selecting the
correct entry in the
New dropdown menu in the top right