How to use Anaconda to manage packages and environments

Zihan Guo
Data Alchemist
Published in
2 min readMay 25, 2019

A concise list of useful conda commands

Let machines do the work

Background

Inside and outside of work, Anaconda has been an essential tool for me to manage packages and environments. In a nutshell, Anaconda is a distribution of packages specialized for Data Scientists. The package and environment manager for Anaconda is called conda.

why conda?

So don’t we just usepip, another popular package manager? There are couple of reasons that I can think of:

  • Downloading anaconda takes some time and as of today, it occupies around half Gigabytes of data. This is because anaconda comes with pre-installed packages that most Data Scientists need.
  • Not only can Anaconda be used as a package manager likepip, it also has the ability to manage environments like virtualenvor pyenv.

Useful Commands

  • conda create -n environment_name python=3.x where -n means new, environment_name should be replaced with the name of the environment, x indicates the python version e.g. 3.5, 3.6, 3.7 or even 2.7 (but python 2 will soon be deprecated so please use 3.x)
  • conda activate envrionment_name to activate an environment
  • source deactivate or conda deactivate to deactivate an environment
  • conda install package_name or conda uninstall package_name
  • one can also do conda env export > environment.yaml to export the environment, and useconda env create -f environment.yaml to re-create that environment
  • conda env list to list all environment
  • conda env remove -n env_name to remove a certain environment

Go Beyond

To learn more about useful condacommand, check out its official command reference:

Reference

[download anaconda] https://www.anaconda.com/download/.

--

--