Create a conda environment¶
Load the conda module¶
The software conda is installed into the module Miniforge3. We must load it before to use it.
Create a conda environment¶
An environment allows to install a set of softwares and libraries without interfering with the rest of the system.
Which packages can be installed?¶
The website https://anaconda.org can be used to search available packages. The search can also be performed using the following command:
How to create an environment?¶
The command conda create is designed for this purpose:
This command will create an environment at the path </path/to/my/env> in which <pkg1> and <pkg2> will be installed.
Example
We want to create an environment compare-align where blast+ and diamond will be installed. This environment will be created into the directory ~/work/my-project/envs/
- conda-forge
- bioconda
- nodefaults
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done
...
We check that the enviromnent is created in the right place:
...
base /usr/local/bioinfo/src/Miniforge/Miniforge3
...
/work/<username>/my-project/envs/compare-align
...
Alternative
It is possible to replace the option -p by -n.
In this case, the environment will be created at ~/.conda/envs/<env-name>.
Example
We create again a environment name compare-align:
We check the place where the environment was created:
...
compare-align /home/<username>/.conda/envs/compare-align
...
base /usr/local/bioinfo/src/Miniforge/Miniforge3
...
How to install a precise version of a software?¶
You can use notations =, ==, !=, <=, <, >= and > in order to target package versions.
Examples
-
Create an environment containing
Rversion 3.6.x:# We create the env\(">conda create -p ~/work/envs/R-3.6 "r-base=3.6"</span><span data-ty>...</span><span class="termynal-comment" data-ty># We check which R is installed</span><span data-ty="input" data-ty-prompt="\)">source activate ~/work/envs/R-3.6conda list# packages in environment at /home/<username>/work/envs/R-3.6:# # Name Version Build Channel...
r-base 3.6.3 hbcea092_8 conda-forge
... -
Create an environment with last
python 2version andnumpy:# We want the last version before python 3# but also something after python 2.6 (i.e. python 2.7.y)\(">conda create -p ~/work/envs/python-2.7 "python>2.6,<3" numpy</span><span data-ty>...</span><span class="termynal-comment" data-ty># We check which python version is installed</span><span data-ty="input" data-ty-prompt="\)">source activate ~/work/envs/python-2.7conda list# packages in environment at /home/<username>/work/envs/python-2.7:# # Name Version Build Channel...
python 2.7.15 h5a48372_1011_cpython conda-forge
...
Escape characters
Make sure to use " when using > et <.
How to use a specific channel?¶
Sometime, a package is available in a channel you haven't configured. You can use the option -c or --channel to install it without altering your conda configuration.
Conda install
This option can also be used with the conda install command.
Example
Install DESeq2 from bioconda channel and R, which is a dependency, from conda-forge channel.
Channel priority
The further to the left of the command the channel appears, the lower its priority: conda-forge channel has priority over bioconda if a package exists in both channels.