DEV Community

Cover image for Anaconda Cheatsheet
milindsoorya
milindsoorya

Posted on • Updated on • Originally published at milindsoorya.com

Anaconda Cheatsheet

What is anaconda?

Anaconda is a python package manager and it is really amazing, it is popular because it brings many of the tools used in data science and machine learning with just one install.

In a previous article I talked about how to create a virtual environment using anaconda, you can check it out here. 🐍

In this article, I will list out some of the important anaconda commands. Let's jump right in.

Here on out I will use conda to refer to anaconda

Check if conda is installed and in your PATH if not install from here

conda -V
Enter fullscreen mode Exit fullscreen mode

Check if conda is up to date

conda update conda
Enter fullscreen mode Exit fullscreen mode

Search for python versions in conda

conda search "^python$"
Enter fullscreen mode Exit fullscreen mode

Use conda to create a barebone virtual environment

conda create -n yourenvname python
Enter fullscreen mode Exit fullscreen mode

Use conda to create a virtual environment containing most of the popular data science tools

conda create -n yourenvname python=x.x anaconda
Enter fullscreen mode Exit fullscreen mode

Activate your virtual environment in conda

# if you are using a UNIX operating system like ubuntu
source activate *yourenvname*

# if you are using windows
conda activate yourenvname
Enter fullscreen mode Exit fullscreen mode

Install additional Python packages to a conda virtual environment.

Failure to specify “-n yourenvname” will install the package to the root Python installation.

conda install -n yourenvname [package]
Enter fullscreen mode Exit fullscreen mode

Deactivate your conda virtual environment.

conda deactivate
Enter fullscreen mode Exit fullscreen mode

List all conda virtual environments

conda env list
Enter fullscreen mode Exit fullscreen mode

Delete a no longer needed conda virtual environment

conda remove -n yourenvname -all
Enter fullscreen mode Exit fullscreen mode

Find where your conda virtual environment is stored

Before running the below code, make sure you activated your virtual environment

# on MacOS/Linux:
echo $CONDA_PREFIX

# on Windows:
echo %CONDA_PREFIX%
Enter fullscreen mode Exit fullscreen mode

To find path of all conda environments

conda info --envs
Enter fullscreen mode Exit fullscreen mode

That's it, thanks for reading, if you have some code to share please share in the comment section I will add it to the above list.

Don't forget to bookmark this page for future reference 🐱‍👤

Top comments (0)