Skip to content
kd
25 Dec 2015
Back to blog

Using conda to manage packages

2 min read (257 words)

Table of contents

Why use conda

The following quote is from Conda's github page conda/conda.

Conda is a cross-platform, Python-agnostic binary package manager. It is the package manager used by Anaconda installations, but it may be used for other systems as well. Conda makes environments first-class citizens, making it easy to create independent environments even for C libraries. Conda is written entirely in Python, and is BSD licensed open source.

The main advantage of using conda to manage your packages and environment is that it will work across platforms. Conda also uses hard linking, so it is inexpensive to create multiple copies of the same package

How to

One simple way to start is to first specify a environment.yml file

environment.yml
name: psst-env
dependencies:
- python
- nose
- numpy
- pandas
- pip:
- pyomo

The name of the environment can be changed. Activate the environment by using the following.

Terminal window
source activate psst-env

Then you can create the environment by

Terminal window
conda env create

You can update the environment after adding a package to environment.yml by using the following

Terminal window
conda env update

Alternatively, you can create a new empty environment by using either one of the following

Terminal window
conda create -n pelican-env python=2
conda create --name pelican-env python=2

In this case, pelican-env is the name of the environment. You can follow the name of the environment with all the packages you want separated by spaces. You must have at least one package to create a environment.

After the environment is created, you can source the environment :

Terminal window
source activate pelican-env

You can install packages here using one of the following :

Terminal window
conda install <PACKAGE-NAME>

When you have set up the environment and would like to share it, you can run the following to generate a .yml file

Terminal window
conda env export

I like to update by environment.yml by running the following

Terminal window
conda env export > environment.yml

Citation

@online{krishnamurthy2015usingcondatomanagepackages,
  author = {Dheepak Krishnamurthy},
  title = {Using conda to manage packages},
  year = {2015},
  date = {2015-12-25},
  url = {https://kdheepak.com/blog/using-conda-to-manage-packages/},
  langid = {en},
}

For attribution, please cite this work as:

Dheepak Krishnamurthy, "Using conda to manage packages", December 25, 2015 https://kdheepak.com/blog/using-conda-to-manage-packages/


Neovim and Tmux
Writing technical papers with Markdown and Pandoc