Installing anaconda python on keeling

Updated 4 August 2016

In this tutorial, we will install anaconda python on DAS’s cluster, keeling.  In theory, you should be able to use many python packages, including the system defaults, but having your own python distribution allows you to install and have control over your own packages without root permissions.  I’m assuming you have a keeling account.  If not, contact SESE computing help.

Note: these instructions are similar to how you would install python on a local machine (i.e., OS X).  I note below where things are different.

Prerequisites

We will first install anaconda python, which is an easy to use python distribution created and maintained by Continuum Analytics.  Install anaconda python by downloading the from from Continuum Analytics. http://continuum.io/downloads

Copy the link to the download for your system type (linux, mac, etc.) in the web browser, and then paste it into your keeling terminal window.  For example, for 64-bit linux (keeing), copy the appropriate download link and paste it into your terminal window.  I suggest downloading the 3.5 python, but since there are a couple of packages that are widely used that are not yet python 3.x compatible, we will add python 2.7 to your stack later.

cd ~
wget [URL you get from copy and pasting from the download page]

Once downloaded, install it by

bash [file you downloaded ending in .sh]

This will install anaconda python into a directory you specify in the installation.  keeling users may want to install anaconda in a one of your group’s data directories, since read/write access typically is much faster than on your home directory.

Anaconda work in the bash shell (and tcsh is the default on keeling, and I am not sure how to change it to the default), so in this setup, you will have to invoke the bash shell when you want to use anaconda python (instead of the default python installed on keeling, which is maintained centrally and lacks some of the packages you may want).

To enter bash, type

bash

You’ll do this every time you run anaconda.  Now let’s set up the environment to work with python.

Test python

If you’re not already in the bash shell, invoke it by typing

bash

Note that on a local OS X machine, this step is typically not necessary as bash is the default shell.  If you have changed it to another shell (i.e., tcsh), then you will need to do this step.

Now, you can start python up to test it.

Python 2.7.11 |Anaconda 4.0.0 (64-bit)| (default, Dec  6 2015, 18:08:32) 
[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
>>> 

Type exit() or Control-D to exit python.

New packages are periodically available within anaconda, so it is probably a good time now (and periodically in the future) to update conda and anaconda:

conda update --all

Adding python 3.x to your python stack

In 2017, python 2.7 will be unsupported.  Python 3.5, as of mid-2016, is the most commonly used version.  However, some packages at this time still require python 2.7 to be installed (one being sharppy, which is a useful thermodynamic sounding tool).  We can have two python environments installed, however.  There are some differences between python 2.7 and 3.5, the most common one being the print statement.  However, python 2.7 can handle almost all python 3.5 syntax, so I suggest coding in python 3.5 style.

To add python 3.5 to your stack, we will use conda to create a separate environment for it.  We will call it py3k.  You can create other environments too if you want to have python stacks that have different packages/versions.  Create an environment like this:

conda create -n py3k python=3.5

Now activate your python 3 environment – you will have to do this to use the tools in that environment:

source activate py3k

Note that your terminal prompt now indicates that you are in the py3k environment.

To leave that evnironment and go back to the default python stack (which for our install is python2.7)

source deactivate

In your new environment, by default only a minimal python environment is installed.  You may want to install packages that are commonly used, like those in the anaconda package.  So in that environment, you can install them by:

source activate py3k

conda install anaconda

Since this python3 stack is independent of the python2 stack, you will want to use the conda update command in that environment too.

conda update --all

 

Leave a Reply

precipitation • cloud dynamics • cloud microphysics • radar meteorology • satellite meteorology • high impact weather