# Anaconda

Anaconda provides a command-line utility called `conda` for installing and managing different versions of the Python programming language and third-party packages.

> Anaconda is a package manager, an environment manager, a Python/R data science distribution, and a collection of over 1,500+ open source packages. Anaconda is free and easy to install, and it offers free community support. - [Anaconda website](https://docs.anaconda.com/anaconda/)

Resources:

* [https://conda.io/docs/\_downloads/conda-cheatsheet.pdf](https://conda.io/docs/_downloads/conda-cheatsheet.pdf)
* [https://conda.io/docs/user-guide/getting-started.html](https://conda.io/docs/user-guide/getting-started.html)
* [https://conda.io/docs/user-guide/tasks/manage-conda.html](https://conda.io/docs/user-guide/tasks/manage-conda.html)
* [https://conda.io/docs/user-guide/tasks/manage-environments.html](https://conda.io/docs/user-guide/tasks/manage-environments.html)
* [https://conda.io/docs/user-guide/tasks/manage-pkgs.html#id2](https://conda.io/docs/user-guide/tasks/manage-pkgs.html#id2)
* [https://conda.io/docs/user-guide/tasks/view-command-line-help.html](https://conda.io/docs/user-guide/tasks/view-command-line-help.html)

## Detection

To check to see if Anaconda is already installed:

```bash
conda --version
#> conda 4.5.12

# Mac Terminal:
which conda
#> /anaconda3/bin/conda

# Windows Anaconda Prompt or Git Bash:
where conda
#> C:\Users\YOUR_USERNAME\Anaconda3\Library\bin\conda.bat
#> C:\Users\YOUR_USERNAME\Anaconda3\Scripts\conda.exe
```

### Detection on Mac

On a Mac, you can invoke these commands directly in the Terminal.

![](https://2741866142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lxirt-fOkHNRdT9uASu%2F-LxyAjPAv2RY6Fzg9ag1%2F-LxyAyTbshCuicuTRn81%2Fmac-terminal.png?generation=1578370079549028\&alt=media)

### Detection on Windows

However, on Windows, you can alternatively search for the "Anaconda Prompt" application to know whether or not you have it installed.

![](https://2741866142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lxirt-fOkHNRdT9uASu%2F-LxyAjPAv2RY6Fzg9ag1%2F-LxyAyTdeAN1mgjqYp4V%2Fwindows-detecting-anaconda-prompt.png?generation=1578370078471591\&alt=media)

After the Anaconda Prompt is installed, you can invoke `conda` commands from within it:

![](https://2741866142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lxirt-fOkHNRdT9uASu%2F-LxyAjPAv2RY6Fzg9ag1%2F-LxyAyTfGI-b6rZstrUY%2Fwindows-anaconda-prompt.png?generation=1578370078614949\&alt=media)

If Anaconda is installed the way we need it to be, we should also be able to invoke `conda` commands from within the Git Bash console:

![](https://2741866142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lxirt-fOkHNRdT9uASu%2F-LxyAjPAv2RY6Fzg9ag1%2F-LxyAyThuAJrxyb2uglR%2Fgit-bash-where-conda.png?generation=1578370078937750\&alt=media)

If Git Bash doesn't recognize your `conda` commands, you might have to uninstall Anaconda and when re-installing it, make sure to check the "Add Anaconda to my PATH environment variable" option (see installation instructions below).

## Installation

If not yet installed, [download Anaconda Version 3.7](https://www.anaconda.com/download) for either Mac or Windows.

> NOTE: This might take a while, so prefer to do it over a strong WiFi connection. And feel free to ignore any email capture forms which may pop up afterwards.

![](https://2741866142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lxirt-fOkHNRdT9uASu%2F-LxyAjPAv2RY6Fzg9ag1%2F-LxyAyTjObcbTf-2jxtT%2Fdownloading-anaconda-windows.png?generation=1578370079133112\&alt=media)

After the download has finished, run the installer program and accept all the default options, except for this important exception to "Add Anaconda to my PATH environment variable", which will allow other programs like Git Bash to recognize the Anaconda installation:

![](https://2741866142-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lxirt-fOkHNRdT9uASu%2F-LxyAjPAv2RY6Fzg9ag1%2F-LxyAyTlnF2-3Lu8ALOC%2Fanaconda-install-add-to-path.png?generation=1578370079003861\&alt=media)

The installation will take a few minutes to complete.

> NOTE: After installing Anaconda on a Mac, you will need to restart your terminal for the changes to take effect.

After the installation is complete, try repeating the detection commands again, as described in the section above.

Once you are able to successfully detect your installation of Anaconda, you are ready to proceed!

> NOTE: On Windows, you may need to run the command `conda init bash` when prompted to do so, in order to activate a virtual environment for the first time.

## Usage

### The `conda` Utility

View a list of existing virtual environments:

```bash
conda info --envs
```

Create a new virtual environment, and name it something like "my-first-env":

```bash
conda create -n my-first-env

# FYI: you can specify a Python version for your new environment with...
# conda create -n my-first-env python=3.8

# FYI: you can delete any environment with...
# conda env remove -n my-first-env
```

Enter into, or "activate", the virtual environment:

```bash
conda activate my-first-env

# FYI: to deactivate...
# conda deactivate
```

After activating the environment, you should be able to detect and use its installations of Python and Pip:

```bash
which python #> /anaconda3/envs/my-first-env/bin/python
python --version #> Python 3.6.7 :: Anaconda, Inc.

which pip #> /anaconda3/envs/my-first-env/bin/pip
pip --version #> pip 18.1 from /anaconda3/envs/my-first-env/lib/python3.6/site-packages/pip (python 3.6)
```

For more information, see notes on [the `python` utility](python) and [the `pip` utility](pip).
