Anaconda Virtual Environment in Python

You can create a Python virtual environment for your Anaconda Distribution of Python using “conda” that comes with the distribution. You can get a list of commonly used conda commands by “conda -h” in the the command line.”conda -V” gives you the current version of conda and can be updated with “conda update conda“.

To create an anaconda virtual environment:

conda create -n yourenvname python=x.x anaconda

The above command installs all the packages that comes with anaconda. In order to selectively install packages, you should first install python and then use conda or pip to install packages on an as need basis. For example, the following commands create a Anconda virtual environment with two packages - numpy and scipy:

conda create -n yourenvname python
source activate yourenvname
conda install numpy scipy

To activate the virtual environment:

source activate yourenvname

The above command prepend your python virtual enviornment to your path. To verify, you can say "which python" and you'll see that its pointing to the python in your virtual environment

To de-activate the virtual environment:

source deactivate

Get a list of all anaconda virtual environments:

conda env list

Delete a virtual environment

conda remove -n yourenvname -all 

Conda's official documentation: