Using Conda

Conda is a software package manager used to download software to the Azure cluster. It supports Python, R, Java, C, and much more.  Software packages are pre-compiled so there is less risk of failed installations. 

A conda environment is a special folder (directory) where conda packages can be installed. 


There's a system conda@4.11.0 binary installed under path /sched/anaconda3/bin/conda

For first time conda users, there is a one time initialization to use conda command:

$/sched/anaconda3/bin/conda init bash
@ip-0A260C0B:~# /sched/anaconda3/bin/conda init bash
no change     /sched/anaconda3/condabin/conda
no change     /sched/anaconda3/bin/conda
no change     /sched/anaconda3/bin/conda-env
no change     /sched/anaconda3/bin/activate
no change     /sched/anaconda3/bin/deactivate
no change     /sched/anaconda3/etc/profile.d/conda.sh
no change     /sched/anaconda3/etc/fish/conf.d/conda.fish
no change     /sched/anaconda3/shell/condabin/Conda.psm1
no change     /sched/anaconda3/shell/condabin/conda-hook.ps1
no change     /sched/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change     /sched/anaconda3/etc/profile.d/conda.csh
modified      /root/.bashrc

==> For changes to take effect, close and re-open your current shell. <==


Upon close and re-open the current shell, conda will be loaded to your command path:

(base) root@ip-0A260C0B:~# conda info

active environment : base
active env location : /sched/anaconda3
shell level : 1
user config file : /root/.condarc
populated config files : 
conda version : 4.11.0
conda-build version : 3.21.4
python version : 3.8.8.final.0
...


Base environment is a system environment that is read-only for a normal user. A normal user without sudo access cannot install package in the base environment.

To turn off base environment upon log in:

$ conda config --set auto_activate_base false


You can create any number of conda environments. 

It is best practice to create different environments and isolate tools - especially R tools; e.g., Seurat, to ensure quality and veracity of the tools. 

To create different places/environments for conda, type:      $conda create --prefix /data/lab_account/conda_envs/tool name

Examples:  

$conda create --prefix /data/twestlab/conda_envs/cellranger

$conda create --prefix /data/twestlab/conda_envs/seurat

Here are some common useful conda commands:

## List all conda environments
$ conda env list
# conda environments:
#
base                  *  /sched/anaconda3


## Create a conda environment with Python version 3.9
$ conda create --name pandaexpress python=3.9


## Activate a conda environment
$ conda activate pandaexpress
(pandaexpress) @ip-0A260C0B:~$ 


## Deactivate a conda environment
$ conda deactivate
@ip-0A260C0B:~$ 


## Delete a conda environment
$ conda env remove --name <name-of-env>


## List all packages installed in the conda environment, 
## or add --revisions flag to show revision history
$ conda list
$ conda list --revisions


## Restore the environment to the previous revision
$ conda install --revision 2


## Search and install a package
$ conda search <package-name>
$ conda install <package-name>



For more conda command cheatsheet: https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf