Usage & Installation : Anaconda

Anaconda is a completely free Python distribution (including for commercial use and redistribution). It includes over 195 of the most popular Python packages for science, math, engineering, data analysis. See official page : http://docs.continuum.io/anaconda/index.html

Download Anaconda

You can get the Linux installer via : https://docs.continuum.io/anaconda/install/linux/
It’s big … arround ‘350MB’.
You can download these installer inside /tmp or /localstorage.

Install Anaconda

You can read the official documentation here : http://docs.continuum.io/anaconda/install.html

For the fast way to use, you just have to do :

$ bash Anaconda-2.x.x-Linux-x86[_64].sh

Note : You do NOT need root privileges to install Anaconda, if you select a user writable install location, such as /localstorage.
I really recommand you to install Anaconda in the /localstorage of your host.
A normal light installation is around 1,5G so you will use a big part of your Sismo’s quota juste for that.

Anaconda will now be installed into this location:
/home/yourlogin/anaconda

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify an different location below

[/home/yourlogin/anaconda] >>>

Please here change the path to something in your /localstorage

[/home/yourlogin/anaconda] >>> /localstorage/Ana/Conda

user $PATH

Static way

You may wish to edit your .bashrc or prepend the Anaconda install location:

$ export PATH=/localstorage/Ana/Conda/bin:$PATH

With this env you will use Anaconda Python :

$  which python
/localstorage/Ana/Conda/bin/python

Without you will use the system one :

$  which python
/usr/bin/python

Be carreful of what you want and when abou your $ENV and $PATH.

Dynamic way

You can add aliases in your .bashrc to activate and deactivate anaconda ENV with a simple command.

$ cat ~/.bash_alias | grep 'alias conda'
alias conda_activate='source /home/thomas/anaconda/bin/activate ~/anaconda'
alias conda_deactivate='source /home/thomas/anaconda/bin/deactivate'
$

To activate Anaconda mode :

$ conda_activate
discarding /localstorage/Ana/Conda/bin from PATH
prepending /localstorage/Ana/Conda/bin to PATH
(/localstorage/Ana/Conda)$

To switch off Anaconda mode :

$ conda_deactivate
discarding /localstorage/Ana/Conda/bin from PATH
$

add channel

Add the conda-forge channel to your Anaconda configuration:

$ conda config --add channels conda-forge

Exemple install package

Easy way

I want to install a new matplotlib version.

In first I search with conda:

$ conda search matplotlib
Fetching package metadata: ..
matplotlib                   1.1.1                np17py27_0  defaults
                             1.1.1                np17py26_0  defaults
                             1.1.1                np16py27_0  defaults
[...]
                             1.4.0                np19py33_0  defaults
                          *  1.4.0                np19py27_0  defaults
                             1.4.0                np19py26_0  defaults
[...]
                             1.4.2                np19py33_0  defaults
                             1.4.2                np19py27_0  defaults
                             1.4.2                np19py26_0  defaults
$

Here I can see that I’ve the 1.4.0 version of matplotlib already install for Python2.7.

If I want the 1.4.2 I’ve just to do from my Anaconda ENV :

(/localstorage/Ana/Conda)$ conda install matplotlib=1.4.2

Hard way

I can’t find my package with ‘conda search’ :

Exemple with evtj Python package : pyevtk

$ conda search evtk
Fetching package metadata: ..
$

Go to pyevtk web site : https://bitbucket.org/pauloh/pyevtk

Download and unzip it :

$ wget [https://bitbucket.org/pauloh/pyevtk/get/0e1a3d558c34.zip]  
$ unzip 0e1a3d558c34.zip  

Then inside your Anaconda.
For exemple in my case I install it in : /localstorage/Ana/Conda

So inside the unzip pauloh-pyevtk-0e1a3d558c34 I just do :

$ /localstorage/Ana/Conda/bin/python setup.py install

You can check that it’s install with :

$ conda list | grep evtk
evtk                      1.0.0                     <pip>

And then I can use it …

$ python
Python 2.7.8 |Anaconda 2.1.0 (64-bit)| (default, Aug 21 2014, 18:22:21)
[...]
>>> import evtk
>>> 

Virtual Env

Anaconda VirtualEnv creation

Let’s create an environment with NumPy 1.6.

(/localstorage/Ana/Conda)$ conda create -n np1.6 anaconda numpy=1.6

And next, let’s create an environment for NumPy 1.7:

(/localstorage/Ana/Conda)$ conda create -n np1.7 anaconda numpy=1.7

View all your Conda Envs

(/localstorage/Ana/Conda)$ conda info -e

Activate an environnement :

(/localstorage/Ana/Conda)$ source activate myenv

Full example Python 3.5.1 with Obspy 1.0.2

In This exemple I wan’t in a new VirtualEnv name ‘py351-obspy’ with packages python 3.5.1 and Obspy 1.0.2 :

$ cd /localstorage/Anaconda/bin
$ source activate
(anaconda) $ conda create -n py351-obspy python=3.5.1 obspy=1.0.2
[...]
The following NEW packages will be INSTALLED:
[...]
obspy:           1.0.2-py35_1       conda-forge
[...]
Proceed ([y]/n)? y
[...]
(anaconda) $ source activate py351-obspy
(py351-obspy) 

More about ENV here : http://conda.pydata.org/docs/faq.html#environments

Official Documentation

http://www.continuum.io/
http://conda.pydata.org/index.html
http://conda.pydata.org/docs/index.html