Anaconda is a free Python distribution for data analysis and scientific computing. It has its own package manager, conda. The distribution includes more than 200 Python packages, which makes it very convenient. For casual users, the Miniconda distribution may be the better choice. Miniconda contains the conda package manager and Python. The technical editors use Anaconda, and so do I. But don't worry, I will describe in this book alternative installation instructions for readers who are not using Anaconda. In this recipe, we will install Anaconda and Miniconda and create a virtual environment.
The procedures to install Anaconda and Miniconda are similar. Obviously, Anaconda requires more disk space. Follow the instructions on the Anaconda website at http://conda.pydata.org/docs/install/quick.html (retrieved Mar 2016). First, you have to download the appropriate installer for your operating system and Python version. Sometimes, you can choose between a GUI and a command-line installer. I used the Python 3.4 installer, although my system Python version is v2.7. This is possible because Anaconda comes with its own Python. On my machine, the Anaconda installer created an anaconda
directory in my home directory and required about 900 MB. The Miniconda installer installs a miniconda
directory in your home directory.
$ conda list
$ conda list --export
$ conda create -n ch1env --file <export file>
This command also creates an environment named ch1env
.
testenv
environment:$ conda create --name testenv python=3
$ source activate testenv
source
. The syntax to switch back is similar:$ source deactivate
$ conda env export -n testenv
~/.conda/environments.txt
):$ conda remove -n testenv --all
$ conda search numpy
In this example, we searched for the NumPy package. If NumPy is already present, Anaconda shows an asterisk in the output at the corresponding entry.
$ conda update conda
The .condarc
configuration file follows the YAML syntax.
YAML is a human-readable configuration file format with the extension .yaml
or .yml
. YAML was initially released in 2011, with the latest release in 2009. The YAML homepage is at http://yaml.org/ (retrieved July 2015).
You can find a sample configuration file at http://conda.pydata.org/docs/install/sample-condarc.html (retrieved July 2015). The related documentation is at http://conda.pydata.org/docs/install/config.html (retrieved July 2015).