Skip to content
Published On:
Jan 17, 2018
Last Updated:
Jan 17, 2018

Anaconda exposes two important command-line tools, conda and source.

The logo for Anaconda (Python distribution/environment).

How To Create And Use A Virtual Environment

This assumes you have installed anaconda and conda is available on your path.

First, create a new environment:

Terminal window
$ conda create -n <your environment name>

Now activate this environment:

Terminal window
$ source activate <your environment name>

Install your required packages:

Terminal window
$ conda install -n <your environment name> <package>

Now you can run your python code!

When finished, you can deactivate your virtual environment with:

Terminal window
$ source deactivate

Listing All Local Environments

Use the following command to list all local environments:

Terminal window
$ conda env list

The currently active environment will have an asterisk after it’s name.

Installing Non-Conda Packages

Non-conda packages can be installed into the current environment with other Python package managers such as pip:

Terminal window
$ pip install <package name>

As long as a Anaconda environment is active, pip will install to the current environment only.