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:

Now activate this environment:

Install your required packages:

Note: If you don’t specify an environment to install to (as above), Anaconda will install to the currently active environment. To install to any environment which is not currently active, add the option -n <your environment name> to the above command.

Now you can run your python code!

When finished, you can deactivate your virtual environment with:

Listing All Local Environments

Use the following command to list all local environments:

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:

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

Posted: January 18th, 2018 at 7:17 am
Last Updated on: February 2nd, 2018 at 6:53 am