Appendix A. Go Forth and Explore Visualization

Python has been around since 1991 and has gained popularity among the community of scientists and engineers. Among many libraries, numpy, scipy, and matplotlib have been widely used in scientific computing. Sage covers the areas of algebra, combinatorics, numerical mathematics, number theory, and calculus using an easy browser interface via IPython. Another popular package called pandas can be used to store and process complex datasets.

There are multiple tools to run and edit Python programs, and one among them is Anaconda from Continuum. One of the advantages of Anaconda is that it does not cost anything and comes inbuilt with most necessary packages. The underlying command-line tool for managing environments and Python packages is conda, and the editor is Spyder.

In the past, installing Spyder was complicated because it involved downloading and installing it in a multistep process. Installation in the recent versions has been very straightforward, and one can download and install all the components together automatically in one step.

An overview of conda

Conda is a command line-tool that is responsible for managing environments and Python packages, rather than using pip. There are ways to query and search the packages, create new environments if necessary, and install and update Python packages into the existing conda environments. This command-line tool also keeps track of dependencies between packages and platform specifics, helping you to create working environments from different combinations of packages. To check the version of conda that is running, you can enter conda --version in Python and it will show, for example, conda 3.18.2 as the version.

A conda environment is a filesystem directory that contains a specific collection of conda packages. To begin using an environment, simply set the PATH variable to point it to its bin directory.

Here is an example of the package installation from the command line using conda:

$ conda install scipy

Fetching package metadata: ....
Solving package specifications: .
Package plan for installation in environment /Users/MacBook/anaconda:

The following packages will be downloaded:

    package                |       build
    ---------------------|-----------------
    flask-0.10.1         |       py27_1         129 KB
    itsdangerous-0.23    |       py27_0          16 KB
    jinja2-2.7.1         |       py27_0         307 KB
    markupsafe-0.18      |       py27_0          19 KB
    werkzeug-0.9.3       |       py27_0         385 KB

The following packages will be linked:

    package              |            build
    ---------------------|-----------------
    flask-0.10.1         |       py27_1
    itsdangerous-0.23    |       py27_0
    jinja2-2.7.1         |       py27_0
    markupsafe-0.18      |       py27_0
    python-2.7.5         |       2
    readline-6.2         |       1
    sqlite-3.7.13        |       1
    tk-8.5.13            |       1
    werkzeug-0.9.3       |       py27_0
    zlib-1.2.7           |       1

Proceed ([y]/n)? 

Any dependencies on the package that we are installing will be recognized, downloaded, and linked automatically.

Here is an example of package update from the command line using conda:

$ conda update matplotlib
Fetching package metadata: ....
Solving package specifications: .
Package plan for installation in environment /Users/MacBook/anaconda:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    freetype-2.5.2             |                0         691 KB
    conda-env-2.1.4            |           py27_0          15 KB
    numpy-1.9.2                |           py27_0         2.9 MB
    pyparsing-2.0.3            |           py27_0          63 KB
    pytz-2015.2                |           py27_0         175 KB
    setuptools-15.0            |           py27_0         436 KB
    conda-3.10.1               |           py27_0         164 KB
    python-dateutil-2.4.2      |           py27_0         219 KB
    matplotlib-1.4.3           |       np19py27_1        40.9 MB
    ------------------------------------------------------------
                                           Total:        45.5 MB

The following NEW packages will be INSTALLED:

    python-dateutil: 2.4.2-py27_0    

The following packages will be UPDATED:

    conda:             3.10.0-py27_0    --> 3.10.1-py27_0   
    conda-env:       2.1.3-py27_0     --> 2.1.4-py27_0    
    freetype:   2.4.10-1         --> 2.5.2-0         
    matplotlib:     1.4.2-np19py27_0 --> 1.4.3-np19py27_1
    numpy:          1.9.1-py27_0     --> 1.9.2-py27_0    
    pyparsing:      2.0.1-py27_0     --> 2.0.3-py27_0    
    pytz:           2014.9-py27_0    --> 2015.2-py27_0   
    setuptools:     14.3-py27_0      --> 15.0-py27_0     

Proceed ([y]/n)?

In some cases, there are more steps involved in installing a package via conda. For instance, to install wordcloud, you will have to perform the steps given in this code:

#step-1 command
conda install wordcloud

Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: wordcloud

You can search for this package on Binstar with
# This only means one has to search the source location
binstar search -t conda wordcloud

Run 'binstar show <USER/PACKAGE>' to get more details:
Packages:
                          Name | Access       | Package Types   | 
     ------------------------- | ------------ | --------------- |
             derickl/wordcloud | public       | conda           |
Found 1 packages

# step-2 command
binstar show derickl/wordcloud

Using binstar api site https://api.binstar.org
Name:    wordcloud
Summary:
Access:  public
Package Types:  conda
Versions:
   + 1.0

To install this package with conda run:
conda install --channel https://conda.binstar.org/derickl wordcloud

# step-3 command
conda install --channel https://conda.binstar.org/derickl wordcloud

Fetching package metadata: ......
Solving package specifications: .
Package plan for installation in environment /Users/MacBook/anaconda:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cython-0.22                |           py27_0         2.2 MB
    django-1.8                 |           py27_0         3.2 MB
    pillow-2.8.1               |           py27_1         454 KB
    image-1.3.4                |           py27_0          24 KB
    setuptools-15.1            |           py27_1         435 KB
    wordcloud-1.0              |       np19py27_1          58 KB
    conda-3.11.0               |           py27_0         167 KB
    ------------------------------------------------------------
                                           Total:         6.5 MB

The following NEW packages will be INSTALLED:
    django:     1.8-py27_0
    image:      1.3.4-py27_0
    pillow:     2.8.1-py27_1
    wordcloud:  1.0-np19py27_1

The following packages will be UPDATED:
    conda:      3.10.1-py27_0 --> 3.11.0-py27_0
    cython:     0.21-py27_0   --> 0.22-py27_0
    setuptools: 15.0-py27_0   --> 15.1-py27_1



Finally, the following packages will be downgraded:

    libtiff:    4.0.3-0       --> 4.0.2-1

Proceed ([y]/n)? y

Anaconda is a free Python distribution for scientific computing. This distribution comes with Python 2.x or Python 3.x and 100+ cross-platform tested and optimized Python packages. Anaconda can also create custom environments that mix and match different Python versions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset