Anaconda memo

Managing Conda and Anaconda

Verify conda is installed, check version

Get the version

1
conda --version
1
conda info

Update conda package and environment manager

1
conda update conda

Update the anaconda meta package

1
conda update anaconda

Managing Environments

Get a list of all my Anaconda environments

1
2
3
4
5
conda info --envs

conda env list

# The above two commands are equivalent

Create an Anaconda environment

1
conda create -n env_name

Create an Anaconda environment with a specific version of Python

1
conda create -n env_name python=3.6

Create an Anaconda environment with a specific package

1
2
3
4
conda create -n env_name scipy

# with a specific version of a package 
conda create -n env_name scipy=0.15.0

Create an Anaconda environment from an environment.yml file

1
2
3
4
conda env create -f environment.yml

# The first line of the yml file sets 
# the new environment's name.

In order to create an Anaconda environment file manually, see https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually

Activate an Anaconda environment to use it

1
conda activate env_name

Deactivate the Anaconda environment

1
conda deactivate 

Delete an Anaconda environment

1
conda env remove --name env_name

Installing python packages

1
conda install [PackageName]

If you encounter the error PackagesNotFoundError: The following packages are not available from current channels, do the following:

1
conda config --append channels conda-forge

conda-forge is a GitHub organization containing repositories of conda recipes. Thanks to some awesome continuous integration providers, each repository automatically builds its own recipe in a clean and repeatable way on Windows, Linux and OSX.

If a package cannot be easily installed with pip because of issues with system libraries (e.g. version of gcc), a possible solution is to install the package with conda, which is less dependent on system libraries.

Troubleshooter

References

  • https://kapeli.com/cheat_sheets/Conda.docset/Contents/Resources/Documents/index
  • https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment