Create a conda environment named test1 with latest anaconda package.
conda create -n test1 anaconda
Anaconda is a collection of scientific and data analytic Python packages, it has over 200 packages for python 2.7.x-anaconda including NumPy, Pandas, SciPy, Matplotlib, and iPython.
Install from conda-forge channel (example: emacs)
Conda channels are the remote repository that conda takes to search or download the packages. If you want to install a package that is not in the default Anaconda channel, you can tell conda which channel containing the package, so that conda can find and install.
Conda-forge is a GitHub community-led conda channel, containing general packages which are not in the default Anaconda source. All the packages from conda-forge is listed at https://conda-forge.github.io/feedstocks.
conda install -c conda-forge emacs
Install from bioconda channel (example: stringtie)
Bioconda is another channel of conda, focusing on bioinformatics software. Instead of adding “-c” to search a channel only one time, “add channels” tells Conda to always search in this channel, so you don’t need to specify the channel every time. Remember to add channel in this order, so that Bioconda channel has the highest priority. Channel orders will be explained in next part.
conda config --add channels conda-forge
conda config --add channels defaults
conda config --add channels r
conda config --add channels bioconda
Adding channels will not generate any command line output.
Then, you can install Stringtie from the Bioconda channel
conda install stringtie
All the bioconda packages can be found here: https://bioconda.github.io/recipes.html
If you add multiple channels in one environment using (conda config --add channels <new_channel>), The latest or most recent added one have the highest priority. That means, if there is a same package in different channels, the package version from highest priority channel will overwrite other versions, to either higher or lower.
For example, if you add the channels in different order in the Stringtie example, by switching channel r and channel bioconda. Say, channel R has package A version 0.8 and bioconda has A version 1.0. The environment will have A 0.8 now from channel R, since it’s the highest priority. Then, Stringtie might not work if it need package A 1.0.
If the packages can be found in different channels, the package from the highest priority channel will be installed even if the version of it isn’t newest. The command <conda config --append channels new_channel> puts the new channel at the bottom of the channel list, making it the lowest priority.
Install R and R packages
The Conda package manager is not limited to Python. R and R packages are well supported by a conda channel maintained by the developers of Conda. The R-essentials include all the popular R packages with all of their dependencies. The command below opens R channel by “-c r”, and then install the r-essentials using R channel.
module load python/2.7.x-anaconda
conda install -c r r-essentials
Update R packages
conda update -c r r-essentials
conda update -c r r-<package name>
Install from online source (Example: Theano from GitHub)
If some packages are not in any conda channels, you can still use pip to install them in the conda environment. Here’s an example: Install Theano from Github (https://github.com/Theano/Theano).
We need to add git module first and install the package.
module load git/v2.5.3
You can find the package URL from top right of the Theano git website, by clicking the green button “Clone or downloaded”.
# pip install git+<package web URL>
pip install git+https://github.com/Theano/Theano.git
More conda commands:
1. See all available environments
You can check the list of all separate environments, and it will show * at your current environment. In the figure below, it shows root, since I’m not in any conda environment.
conda env list
2. List all package installed
This will show all the packages and versions you’ve installed.
3. Update packages or conda itself
This will update to the newest version of one package, or conda itself.
conda update <package>
#update conda self
conda update conda
4. Uninstall package from the environment
conda uninstall <package name>
5. Exit current environment:
You can exit, when you finish your work in the current environment.
6. Remove environment
conda env remove --name test2
When you finish your project, you might want to remove the environment. However, it is not recommended because you might want to update some work in this project in the future.
Conda documentation http://conda.pydata.org/docs/get-started.html