Anaconda for everyday computing

Amin Mahpour, PhD
Dec 25, 2019 · 5 min read
Image for post
Image for post
Always download and install the latest version of Anaconda — Screenshot by Amin Mahpour

Why Anaconda?

The short and simple answer is because of dependencies and environments. Anaconda automatically takes care of them for you! It means that Anaconda will save a lot of time for you! The long answer is that open-sourced softwares often times need to be compiled from source code for your system, usually from the scratch. The process of making the source code interpretable by your system is called compiling that can be a very frustrating and time consuming process.

During compilation, the compiler software will look for dependent libraries and softwares that the source code needs to properly run the final compiled code on your system. In case you miss one of those dependent softwares before compilation, the compiler will throw an exception and would fail to produce the final executable software. If you have compiled any software from source code in the past, you have probably learnt it, the hard way of couse, that installing any dependencies and also meeting their requirements can be quite a headache.

That’s where Anaconda comes into the play. Anaconda alleviate all of these issues by keeping the track of dependencies and requirements. It will automatically install those so you don’t have to worry about them. Additionally, if there is an updated version of the software available in future, anaconda can upgrade the software along with any new potential dependencies.

Anaconda was originally designed to facilitate the installation of python-based softwares and packages. However, you can find and install many other binary softwares that were written in other languages (such as C or R).

Install Anaconda

To install anaconda, you will need to head over to the Anaconda website where you can download the graphical or command line installer. Here, we will download the command line installer. If you are going to install Anaconda on a Unix machine (such as a linux or Mac-based computers), you can use the following tutorial.

At the time of writing this document, 2019.10 was the latest version of Anaconda. Please check the URL on the Anaconda website to make sure you are downloading the latest version for your machine.

To begin the download and installation of Anaconda, let’s open a Terminal application.

For Linux-based computers type:

wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh

and for Mac-based computers type:

curl 'https://repo.anaconda.com/archive/Anaconda3-2019.10-MacOSX-x86_64.sh' --output Anaconda3-2019.10-MacOSX-x86_64.sh

Now, run the downloaded file using the following command:

sh Anaconda3-2019.10-Linux-x86_64.sh 

or, if you are using the MacOS:

sh Anaconda3-2019.10-MacOSX-x86_64.sh

You will see a message like the following:

Welcome to Anaconda3 2019.10In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue

To review the license, press the enter button on your keyboard. Keep pressing the enter button until you are presented with the following message:

Do you accept the license terms? [yes|no]

If you answer yes to the question, you will have the option to specify the location where Anaconda will be installed.

Anaconda3 will now be installed into this location:
/Users/yourusername/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below

Press enter to accept the default location.

If everything goes as planned, you will have the option of adding the Anaconda to your PATH. The best way to do this is to allow the installer handle this for you. The installer adds a few lines of code into your ~/.bashrc or ~/.bash_profile that will enable Anaconda on startup.

Finally, to verify the successful installation of Anaconda type:

conda info

Working with environments in Anaconda

Now that you have successfully installed the Anaconda, let’s setup our first working environment where you can install your packages in.

To create a new environment with a default python interpreter (version 3.8) type:

conda create -n myconda38 python=3.8

myconda38 is the name of the environment that I chose. It could have been any name of your choice.

And lastly, activate the environment with

conda activate myconda38

To verify the environment, run python. It should indicate the version number 3.8.

After successful activation of your environment, you can begin installing your desired packages using:

conda install your-package-name

For example, if I need to install numpy package:

conda install numpy

Anaconda will look for the package that you indicated and will output the details of installation process:

Collecting package metadata (current_repodata.json): done
Solving environment: done
The following packages will be downloaded:package | build
---------------------------|-----------------
libopenblas-0.3.6 | hdc02c5d_2 8.5 MB
numpy-1.17.4 | py37hfd23ef0_0 4 KB
numpy-base-1.17.4 | py37ha711998_0 3.8 MB
------------------------------------------------------------
Total: 12.4 MB
The following NEW packages will be INSTALLED:libopenblas pkgs/main/osx-64::libopenblas-0.3.6-hdc02c5d_2
numpy pkgs/main/osx-64::numpy-1.17.4-py37hfd23ef0_0
numpy-base pkgs/main/osx-64::numpy-base-1.17.4-py37ha711998_0

If you choose to install the package, Anaconda automatically retrieve the required dependencies as shown (in this case libopenblas library) and install them for you.

Environments are extremely helpful because you can isolate them. For example, if you have a package that is only compatible with certain version of python, you could create a new environment with that paticular python version. Thus, you don’t need to manually install a different python version on your system that could potentially interfere with other softwares.

If you are interested to know the details of packages are currently installed in your working environment:

conda list

If you are working with a lot of different environments, you can use the following command to list them:

conda env list

Last words

As you can see, it is significantly easier to work with Anaconda than with compilers. It is very convenient to create, modify or remove new environments and even switch between them if needs be.

Although Anaconda was designed with python in mind, you could always install and use R and R libraries directly in an Anaconda environment. This is very important as you can install the latest version of R binary or libraries without any previllage limitations at any time.

These are the simple reasons for why I use Anaconda primarily at the Harvard Medical School computer cluster for my research computing needs.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store