Getting Started with Anaconda 3
Anaconda is a free and open-source distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system “conda” instead of pip, and the packages include binaries in addition to python source libraries. It’s a great tool if you are doing scientific computing and do not want to worry about library mismatches or other common issues with the tools and it allows you to get started using the tools instead of installing them.
Originally I thought Anaconda was for beginners who were not interested in learning about the libraries work, but in a short time I realized it was not a tool for beginners but a very powerful package manager that is useful at all levels.
Installing Anaconda was quite easy since it includes a graphical installer. Once completed there are two ways to verify that you have the correct version installed. The first step is to open a terminal window with the Anaconda environment running and there are two ways to accomplish that.
The first is to launch Anaconda-Navigator.app
and then choose Environments from the left-hand menu and from then next to the root environment (the only environment installed if you just finished installing Anaconda) choose Open terminal
. This opens a terminal window and launches that environment.
The second is to open a terminal window and type source activate root
to activate the root environment.
Next, let’s verify the python version, the version of conda and the currently selected Anaconda environment.
Check the python version
$ python --version
Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
Check the conda version
$ conda --version
conda 4.2.9
Check the Anaconda environment
$ conda info --envs
# conda environments:
#
root * /Users/username/anaconda[/bash]
The environment listed with a * is the current environment.
If you use python often, you should already be using virtualenv or another application for managing your python environments. By installing Anaconda, it seems to clobber the default python environment on the machine. So now, instead of the default being the python that came with OSX, it is instead the Anaconda installed Python.
This is great if you want to use Anaconda most of the time, and it may not be a bad thing in general, but do keep in mind that means your default version of Python has probably changed from 2.7 to 3.5 (or greater depending on when you have installed Anaconda.)
What if you want the default python back? StackOverflow has a great answer to this by Padraic Cunningham, here is the bulk of the answer:
anaconda adds the path to your
.bashrc
so it is found first, you can add the path to your default python to.bashrc
or remove the path to anaconda if you don’t want to use it.You can also use the full path
/usr/bin/python
in bash to use the default python interpreter.If you leave your
.bashrc
file as is, any command you run usingpython
will use the anaconda interpreter, if you want you could also use analias
for each interpreter.You will see something like
export PATH=$HOME/anaconda/bin:$PATH
in your.bashrc
file.So basically if you want to use anaconda as your main everyday interpreter use the full path to your default python or create an
alias
, if you want it the other way around remove theexport PATH=...
. frombashrc
and use full path to anaconda python interpreter.
This is a great response and can help you return your computer back to “normal” post installation if you want that.
You may not need to upgrade after you install, but it is always better to do so so that your new installation is the latest version.
A StackOverflow post by IanSR has a lot more details in it in case you want to know more, but here are the required commands for your new setup.
conda update -n root conda
conda update --all
That is it for getting started with Anaconda, you now have an installed working version of Anaconda! To begin using as you like.
For more information on Anaconda Environment commands, here is the documentation: https://conda.io/docs/user-guide/tasks/manage-environments.html