Puget Systems print logo
Read this article at https://www.pugetsystems.com/guides/917
Dr Donald Kinghorn (Scientific Computing Advisor )

How to Install Anaconda Python and First Steps for Linux and Windows

Written on March 28, 2017 by Dr Donald Kinghorn

A few weeks ago I wrote a blog post titled Should You Learn to Program with Python . If you read that and decided the answer is yes then this post is for you.

Python is a versatile and useful programming language; It's general purpose and allows several different styles of programming (object oriented, procedural, functional etc.), it's a great scripting language, it runs interactively so it's fast to develop and experiment with, it's probably the best "glue" language, has an enormous collection of add-on modules, it's relatively easy to learn, it has a large user base, and it's easy to install and get started with. ... so, lets install and get started!

Why use Anaconda Python?

Python is Free open-source software and so are the vast majority of modules and tools for it. If you use Linux or MacOS then you will have a default Python installed and you can use it. For Windows you have to install something. There are several options for setting up a nice Python development environment but the setup that is becoming "standard" is Continuum Analytics' Anaconda Python. It's well done and has a great tool for managing module packages and build environments called conda. It has a focus on Data Analytics, Machine Learning and numerical computing. There are lots of good reasons to use it.

Anaconda is mostly a free open-source product of Continuum Analytics. Continuum offers paid subscriptions for support, extra capability and "business features". The founders of Continuum are some of the best Python programmers and have written code for several important and widely used Python packages. They deserve support and funding for their work. Starting a business is one way to achieve that. Be aware that when you read documentation free and paid stuff will sometimes be mixed together. This is my only personal complaint and I wanted to get it out of the way up-front.

Here are some of the reasons to use Anaconda

How to Install Anaconda Python

I'll go through the Linux and Windows install. (It is also simple to install on MacOS but I won't discus it here). After the simple install instructions I'll give you a couple of pointers and links to get you started using your new Python.


I'm using Ubuntu 16.04 but the install procedure should be the same for any Linux version or distribution. The install is via a shell archive script. It's trivial to install.

  1. Point your web browser at the the Continuum downloads page https://www.continuum.io/downloads. Download the latest version of the shell archive -- which was Anaconda3-4.3.1-Linux-x86_64.sh when I wrote this. If you think you will need to use Python 2.7 don't worry about it now. The version you are installing at this point is what will be your default base. You can use any Python version you want when you setup environments for your projects. The conda tool will get the version you want for a specific project automatically.

  2. It's a good idea to check the sha256 hash for the file you just downloaded. (You don't have to do this but it is good practice.) Go to https://docs.continuum.io/anaconda/hashes/ and follow the link to the version you downloaded and look at the page. You will see information about when the file was created, size and the hashes. Then generate a hash on your local machine and check that you have the same code.

kinghorn@u1604ML:~$ sha256sum Anaconda3-4.3.1-Linux-x86_64.sh

which outputs,

4447b93d2c779201e5fb50cfc45de0ec96c3804e7ad0fe201ab6b99f73e90302  Anaconda3-4.3.1-Linux-x86_64.sh

That checked out OK for me.

  1. Now you just need to run the install script. It will unpack the archive and set things up for you.

bash Anaconda3-4.3.1-Linux-x86_64.sh

You will be asked to read a license agreement and then it will offer you a default install location and option to change that. After it finishes installing it will offer to append your PATH variable with the anaconda3/bin directory. You can exit the term session you were using and start another and you will have the new PATH variable set. You are done with the install!

Windows 10

The Windows install is similar to the Linux install but instead of a shell acrhive it's a self extracting installer exe file.

  1. Point your web browser at the the Continuum downloads page https://www.continuum.io/downloads. Download the latest version of the Windows installer -- which was Anaconda3-4.3.1-Windows-x86_64.exe

  2. After downloading just double click the installer exe and follow the prompts. It will by default install in the directory Anaconda3 in your home directory and will offer to add the anaconda bin directory to your PATH variable. Same as it did with the Linux install.

Getting started with Anaconda Python

Your initial interaction with anaconda Python will be through the terminal. Now that the anaconda directory is on your PATH, Python 3.6 should be your default. Try it,

kinghorn@u1604ML:~$ python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello Pyhton")
Hello Pyhton

On Windows you will have new start menu items from the anaconda Python install,

Win 10 anaconda Python menu

If you open the app "Anaconda Prompt" you can do the same thing I just did on Linux,

(C:\Users\don\Anaconda3) C:\Users\don>Python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello Python")
Hello Python

That >>> symbol is the Python interpreter prompt that you can use interactively. To exit from the python session you can type Ctrl-D in Linux or Ctrl-Z in Windows or quit() in either one.

On Linux you can type ipython or in Windows click the ipython icon and you will get an enhanced interactive Python shell that has many useful features.

You can work with Python from the command-line interactively and use a program editor to work on a Python script or module and execute it from the Python prompt. This is the traditional way of working and is simple and efficient.

You can also use Python from the command-line as a "super" calculator. That's something I do often.

Jupyter notebook

Working from the command-line is fine but there is a very powerful and popular browser based notebook interface Jupyter. This may become your main tool for interacting with Python. Jupyter evolved from ipython and is now a surprisingly useful interface for many languages (not just Python).

With Jupyter you can have documentation in Markdown, nice mathematical equations with LaTeX, graphs, plots, images, executable code and output all in the same document. I am currently reading a book that was written using Jupyter! ( "Introduction to Machine Learning with Python", by Sarah Guido; Andreas C. Müller O'Reilly Media, Inc., 2016 )

To start Jupyter just type jupyter notebook in Linux or click on the Jupyter Notebook icon in Windows. You will want to spend some time reading the documentation and experimenting with Jupyter.

There is an interesting (and large!) collection of Jupyter notebooks here https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks. These links will lead to notebooks that "should" open in the notebook viewer nbviewer so that you can read them on-line. If you find something that you want to download and open in your own copy of Jupyter to edit and work with then look for the download icon in the nbviewer to get it. If the notebook opens in a GitHub page then you will need to "git clone" or download the zip file from GitHub to get the files. Warning: Unfortunately if you try to save the file with your browser from the GitHub listing directly you will just get the html rendered version of the notebook which will not open in Jupyter and it will have the same .ipynb file extension!

I recommend you start slow, read the documentation and tutorials and experiment. Keep in mind that your default Python is the latest 3.6 version and you may run across old notebook files that may be written for Python 2.7 and you could have some trouble with them unless you open them in a 2.7 notebook session. You can do that! But you will have to install some other python versions in anaconda. Which we will look at doing in the next section.

Conda and Anaconda Navigator

One of the useful things about Anaconda Python is its tools for Python package management and project environments. The core tool for this is the command-line utility conda. There is also a new GUI tool called "Anaconda Navigator". I'm only going to talk about conda since I haven't spent much time with "Anaconda Navigator" yet. If you want to start with "Navigator" it is still a good idea to learn a little conda first so you understand what the GUI is actually trying to do. After you are familiar with coda are encouraged to look at "Anaconda Navigator" since it does collect several resources including useful links to documentation.

Why is Conda or "Anaconda Navigator" Important?

  • Package management: There are tens of thousands of Python packages (including 100's of useful ones :-). Linux distributions will have a default Python (2 and 3) and many Python packages in their repositories. If you use these packages you are limited in variety and versions (and quality of build). They also get installed globally on your system. There is also the powerful Python pip command that you can use to install packages from PyPI. These options can be difficult to manage for specific projects also version control and, especially updates, are problematic. With conda you can easily update your current environment (more on that in a bit...) and you can setup a work environment with control over versions used. It is a very powerful tool for installing packages and can even install a completely different version of Python than what you setup with your default install.

  • Environments: When you are working on a project you will need a variety of packages and possibly specific version of those packages. (Think of what you might want for a web development project vs a machine learning project). Python developers have been using virtual environments or complete virtual machines for this. There are existing tools for this like virtualenv or for virtual machine management Vagrant. These tools are useful but conda is very versatile and powerful for these tasks.

How to learn Conda

I'll give a couple of example of using conda but first here are some suggestion to get started.

That will get you started and it wont take long for you to realize how powerful and useful conda is.

A few examples of using conda

Add a Python 2.7 environment

I said earlier that we could add a Python 2.7 version. Here's a way to add an environment with the packages you would have installed if you had used the Python 2.7 version of Anaconda as your default install.

Look at your current environments,

conda info --envs
# conda environments:
root                  *  /home/kinghorn/anaconda3

Now lets add Python 2.7

conda create --name python2.7  python=2.7 anaconda

That creates a directory python2.7 in the default anaconda3/envs directory, sets the python version to 2.7 (latest) and then installs the meta-package "anaconda". That's all of the default Anaconda packages for Python 2.7.

Note: If you use --prefix as suggested in the "conda cheatsheet" it creates the directory and environment but doesn't correctly add to the env list. I recommend you just use "--name".

To use this environment,

source activate python2.7

Now typing python gives

(/home/kinghorn/anaconda3/envs/python2.7) kinghorn@u1604ML:~$ python
Python 2.7.13 |Anaconda 4.3.1 (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

To leave that environment,

source deactivate

Note: On Windows leave off the command source i.e. just use activate or deactivate.

Install Intel Python with conda

There is an Intel "channel" on conda-forge (Also see Anaconda Cloud).

conda config --append channels intel
conda create --name intelPython3 -c intel intelpython3_full=2017.0.2
source activate intelPython3
(/home/kinghorn/anaconda3/envs/intelPython3) kinghorn@u1604ML:~$ python
Python 3.5.2 |Intel Corporation| (default, Feb  5 2017, 09:07:18)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution

Yes, it was that easy to install Intel Python!

Setup a Python Machine Learning environment

Lastly lets do an environment for some machine learning experimentation.

conda create --name Py-ML numpy scipy pandas scikit-learn bokeh matplotlib

Ready for some data analysis and machine learning fun!

Happy computing! --dbk

Tags: Python, Programming, Machine Learning
Josh Keenan

Thanks for the guide, Don! I've enjoyed learning Python and this is by far the most comprehensive guide to installing Anaconda I've come across. :) Hope all is well at Puget!

Posted on 2017-03-29 01:42:04

Excellent post. This helped convince me to go with Anaconda python3 on my Windows machines, and I am seriously considering it for my linux machines as well. BTW, my favorite computer workstation was built by Puget Systems. Thanks!

Posted on 2017-10-25 15:20:09
Guest 1997

I installed Python 3.6 in windows 10 64 bit env. Getting connection timed out in below command. Can you help

conda create --name intelPython3 -c intel intelpython3_full=2017.0.2

Posted on 2018-01-10 14:28:01
Donald Kinghorn

If you want the latest 2018 version you should be able to do
conda create --name intelPython3 -c intel intelpython3_full

for 2017 I think
conda create --name intelPython3-2017 -c intel/label/beta2017 intelpython3_full
I just checked and I don't see that in the repo! There is a intelpython3_core with the beta2017 label ???

Posted on 2018-01-11 05:34:50
Mohammod Sohag Mahamud

So i no need not to install python, just anaconda is enough?

Posted on 2018-07-31 14:40:36
Donald Kinghorn

Yes, when you download the installer you will have an option for a version based on Python 3.6 or 2.7 (use the 3.6 version).

Anaconda is a bundle of many useful packages and tools for working with Python. It includes an optimized build of "base" Python.

Later when you get more familiar with using conda or Anaconda Navigator you can add "environments" for different versions of Python and different sets of packages specifically for the project you are working on.

best wishes -Don

Posted on 2018-08-01 17:49:16

Hi Donald,

I've enjoyed this thread and I have been using Anaconda python for some years now. However, I have run into difficulties with Anaconda libraries conflicting with system libraries in my linux distribution. What are your recommendations for dealing with this issue?

Posted on 2020-09-07 00:20:12
Donald Kinghorn

envs! I create an env for everything I'm doing. That way everything is separated and can be specifically versioned as needed. The name space for the env should be isolated from your system. conda create --name ....

You can sometimes have trouble with installed libraries like CUDA for example. I used to set up things like that with environment variables defined in /etc/profile.d so things were set on login. Now I have started just keeping that local so it can be set per shell ...

The biggest change I have made myself, is using docker containers rather than installing stuff directly. For example a build environment for something like compiling TensorFlow from source. I don't want all of that scattered all over my system especially when it is just used for a single project. You can look at my old docker series to see how I set things up for a good single user experience. The series a bit out of date but it gives a pretty good background if it's new to you. Search for "Docker and NVIDIA-docker on your workstation:" in the HPC posts I think there are 5 or 6 posts. That was in 2017 I have newer post where I go through.

I am also getting ready to start writing about a project that some of the docker guys at NVIDIA are doing called "enroot" I like it a lot! It's a much better way to use containers in my opinion.

Hope this helps! I kind of went off on a tangent :-)

Posted on 2020-09-08 15:55:34


Thanks for your (as always) interesting and informative comments.

I've been using environments to some extent, but not knowing what I might need to enable the env to provide everything needed for a given application, I've been using the anaconda or miniconda option on each one, which starts to consume lots of disk space. With this in mind, I like the idea of containers, such as dockers or the new enroot system.

I have another question for you about RTX 30-series and GPU acceleration of MD simulations, but I will post that one in your MD thread.

Posted on 2020-09-09 14:59:20
Donald Kinghorn

Yes, I hear what you are saying ... You can do that, install all of anaconda into an env but it's pretty heavy weight.... as you said.

If you know what you are going to need for a project then you can install everything up front, maybe even use a requirements file but.
This can be good if you are going to need a package that is itself pretty heavy weight like TensorFlow.

But, you don't have to do that.

You can start with a basic env even without installing any packages (you will get a default Python 3 like you would get from miniconda install). The as you need packages you can install as needed. If you have an env active from a command prompt then, anything you install with conda or pip will load into that env. You can just build things out as needed.

These days I use a mix of conda envs and containers. You get good isolation from the system and "project repeatability control".

You may like the stuff I'll write about using "enroot" it's not well know and under active development but I think it is the best container usage solution I've found. I can integrate it into JupyterHub without needing docker or kubernettes. This way containers are just like other jupyter kernel envs

I've just set up the benchmarking I'm going to use for RTX30xx this way. I'm using mostly NVIDIA's performance tuned containers from NGC and 1 or 2 others with custom build environments

Posted on 2020-09-10 16:15:45