PYTHON

Anaconda

Article by:
Date Published:
Last Modified:

Overview

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

The logo for Anaconda (Python distribution/environment).
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:

1
$ conda create -n <your environment name>

Now activate this environment:

1
$ source activate <your environment name>

Install your required packages:

1
$ conda install -n <your environment name> <package>
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:

1
$ source deactivate

Listing All Local Environments

Use the following command to list all local environments:

1
$ 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:

1
$ pip install <package name>

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


Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Related Content:

Tags

comments powered by Disqus