Anaconda

Introduction

Anaconda is a package manager, environment manager and Python distribution with a collection of over 720 open source packages with free community support. With Anaconda, you can query, install and update python packages easily.

Conda commands provide the primary interface to manage environments and packages in Anaconda. You can create environments and control what packages to be installed into the environment. 

The common operations are:

Purpose Command
Verify conda is installed, check version number, see basic information about conda conda info
Get a list of all my environments, active environment is shown with * conda info --envs
List all packages and versions installed in active environment conda list
Create a new environment named py34, specify Python version, install astroid package
NOTE: Environments install by default into the envs directory in your conda directory. You can specify a different path; see conda create --help for details.
conda create -n py34 python=3.4 astroid
Activate the new environment to use it source activate <environment_name>
Deactivate the current environment source deactivate
Delete an environment conda remove --prefix <environment_path> --all
Install a new package in the current environment conda install <package_name>
Update a package in the current environment conda update <package_name>

For the details on Conda commands, please refer to conda cheat sheet and conda documentation.

Default environment in HPC2

You need to source a setup file to use Anaconda. You can choose to use python 2.7 or python 3.6 as the default python version.

To use python 2.7:

source /usr/local/setup/anaconda2.sh

To use python 3.6:

source /usr/local/setup/anaconda3.sh

Depends on the version of python chosen, the default environment is /opt/anaconda2 or /opt/anaconda3. To check the current environment and available packages:

conda info --envs
conda list

 

Environment Installation

You can install environments somewhere in your home directory or group shared directory. If your group members use the same environment, you are advised to install the environment in the group shared directory so that it can be used by all group members.

Intel Distribution for Python

It is a binary distribution of Python interpreter and commonly used packages for computation and data science supporting Python 2 and 3. The packages have been optimized with Intel Performance Libraries to take advantage of parallelism through the use of threading, multiple nodes, and vectorization. As it is under active development, you are advised to install it in your group share directory or home directory if interested.

To install Intel Python in your group shared directory with conda, you can do it as follows.

1. Create the envs direcory in the group shared directory.

mkdir /home/share/<PI>/envs

2. Add the directory as the default installation path in configuration.

conda config --add envs_dirs /home/share/<PI>/envs

Note: the command modifies the optional conda configuration file (~/.condarc), which is automatically created when the first time running the conda config command. You can manage the envs_dirs in the ~/.condarc later.

3. Install Intel Python 3 with environment name ipy3 through Intel Channel with conda:

conda create -n ipy3 -c intel intelpython3_full python=3

Or install the Python 2 with environment name ipy2:

conda create -n ipy2 -c intel intelpython2_full python=2

4. To use the environment:

source activate ipy3

Or

source activate ipy2

5. To exit the current environment:

source deactivate

References: