Using Conda
Conda is a "Package, dependency and environment management (tool) for any language—Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, FORTRAN". Conda installs binaries instead of building packages from source code, so some packages installed with Conda may suffer a performance loss compared to packages built from source. Information on Conda and how to use it can be found on the following links to Conda's site:
Conda is already installed on the Coeus cluster and the stand alone compute servers, so there is no need to install Conda in your home directory.
Getting Started with conda
Conda is available on Coeus and the stand alone compute servers as an environment module. To use Conda and the associated packages, load the module with the following commands on Coeus or the standalone compute servers:
$ module load General/miniconda3/4.8.0
Basic Commands
To output all currently available environments run the following command (currently active environment is indicated with *):
$ conda env list
To load a module execute the following command:
$ source activate environment
(environment) $
To output all packages installed in the current environment:
(environment) $ conda list
# packages in environment at /vol/apps/hpc/stow/miniconda3/4.8.0:
#
# Name Version Build Channel
package_a 1.2.3 0 conda-forge
package_b 3.2.1 py27_0
. . .
To deactivate an environment:
(environment) $ source deactivate
$
Using a Conda Environment
There are many Conda environments available to all users - these can be listed with conda list env, and they have a path in /vol/apps. A user's environments can be listed by having a path in that user's home directory, under ~/.conda/. To install additional packages, it is necessary for a user to create their own Conda environment.
Creating a fresh environment
To create an environment run the following command, specifying that it should have Python v.3.5:
$ conda create --name my_env python=3.5
If you want all of the packages available in another environment, for example the spatial environment available to all users you can create a clone and then add packages.
Cloning an environment
To view the Conda environments, use the below:
$ conda env list
To create the create the clone, named my_clone, from built environment spatial:
$ conda create --name my_clone --clone spatial
The clone can then be activated as the environment and install additional packages:
$ source activate my_clone
(my_clone) $ conda install example_package
Finding/Installing packages
To search for a package, use the search command:
$ conda search example_package
If the package cannot be found, that only means it is not in the default channel. Specify a channel to search with the -c option. Many packages are available on the conda-forge channel:
$ conda search example_package -c conda-forge
Install the package by replacing search with install:
$ conda install example_package
$ conda install example_package -c conda-forge
Removing packages
To remove installed packages, there are two methods: either specify the package and environment, or load the environment and then remove it.
$ conda remove example_package --name my_clone
or
$ source activate my_clone
(my_clone) $ conda remove example_package
Removing an environment
To remove an entire environment, run the following:
$ conda remove --name my_clone --all
Saving/loading a Conda Environment to/from a File
It is possible to save an environment to a file, as well as create an environemnt from a file. This can be beneficial for several reasons, like creating back ups or sharing with a collaborator or moving the work to a different machine.
Saving an environment
Be sure to save the environment as a .yml file.
$ source activate my_env
(my_env) $ conda env export > my_env.yml
Loading an environment
$ conda env create -f my_env.yml