Anaconda, from Anaconda, Inc is a completely free enterprise-ready distribution for large-scale data processing, predictive analytics, and scientific computing. It includes over 195 of the most popular Python packages for science, math, engineering, and data analysis. It also offers the ability to easily create custom environments by mixing and matching different versions of Python and/or R and other packages into isolated environments that individual users are free to create. Anaconda includes the conda package and environment manager to make managing these environments straightforward.
While the standard methods of installing packages via pip
and easy_install
work with Anaconda, the preferred method is using the conda command.
Install miniconda
mkdir ~/conda; cd ~/conda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
To display general information about Conda/Anaconda, use the info
subcommand.
conda info
Conda allows the easy creation of isolated, custom environments with packages and versions of your choosing. To show all currently available environments, and which is active, use the info
subcommand with the -e
option.
conda info -e
The active environment will be marked with an asterisk (*) character.
The list
command will show all packages installed in the currently active environment.
conda list
To find packages, use the search
subcommand.
conda search numpy
Creating Custom Anaconda Environments
The create
command is used to create a new environment. It requires at a minimum a name for the environment, and at least one package to install. For example, suppose we wish to create a new environment and need version 1.17 of NumPy.
Create a new environment by providing a name and package specification
conda create -n mynumpy numpy=1.17
This will create a new environment called ‘mynumpy’ and installed NumPy version 1.17, along with any required dependencies.
To use the environment, we must first activate it.
conda activate mynumpy
Our new environment is now active, and we can use it. The shell prompt will change to indicate this as well.
Adding and Removing Packages from an Existing Environment
To install additional packages in an environment, use the install
subcommand. Suppose we want to install iPython in our ‘mynumpy’ environment. While the environment is active, use install
with no additional arguments.
conda install ipython
If you aren’t currently in the environment you wish to install the package in, add the -n
option to specify the name.
conda install -n mynumpy ipython
The remove
subcommand to uninstall a package functions similarly.
Remove package from currently active environment
conda remove ipython
Remove package from environment specified by name
conda remove -n mynumpy ipython
To exit an environment, we deactivate it.
conda deactivate
Finally, to completely remove an environment, add the --all
option to remove
.
conda remove -n mynumpy --all