Book Image

Learning Python Data Visualization

By : Chad R. Adams
Book Image

Learning Python Data Visualization

By: Chad R. Adams

Overview of this book

<p>The best applications use data and present it in a meaningful, easy-to-understand way. Packed with sample code and tutorials, this book will walk you through installing common charts, graphics, and utility libraries for the Python programming language.</p> <p>Firstly you will discover how to install and reference libraries in Visual Studio or Eclipse. We will then go on to build simple graphics and charts that allow you to generate HTML5-ready SVG charts and graphs, along with testing and validating your data sources. We will also cover parsing data from the Web and offline sources, and building a Python charting application using dynamic data. Lastly, we will review other popular tools and frameworks used to create charts and import/export chart data. By the end of this book, you will be able to represent complex sets of data using Python.</p>
Table of Contents (16 chapters)
Learning Python Data Visualization
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up Python on Ubuntu


Linux-based operating systems such as Ubuntu are Python's home in many ways. The Ubuntu marketplace is written in Python, and many Linux apps usually have a Python code base. Ubuntu features many of the same terminal commands OS X uses, if not the same commands. For Ubuntu, we will focus on Ubuntu 13.10. If you're using a derivative of Ubuntu, Lubuntu, Xubuntu, or Linux Mint, there are a few points that need to be kept in mind.

Most of these commands should be the same, with a few minor differences depending on your setup. Reach out to your search engine of choice if you run into issues loading each software component. The same can be said for Debian or Red Hat-based Linux distros.

Like OS X, you'll need the Java 7 runtime or higher and JDK 7 runtime or higher. Ubuntu does not include these in its included package manager, but you can install them via the command line.

The good news is that Python 2.7 is included with Ubuntu 13.10, so we will not need to install Python. We can even test this by opening the terminal and typing python in the Bash prompt, as shown in the following screenshot:

We will then be taken into the Python interpreter, which will show you the version number of the default Python instance, in this case, 2.7.5+.

The easy_install and pip Python package managers are commonly used to install and update our packages. Next, grab both easy_install and pip, and install both of these tools using the following commands:

sudo apt-get install python-setuptools
sudo apt-get install python-pip

Remember, in Ubuntu the sudo command will ask for a password before installing the python-setuptools and python-pip. Now, if this is successful, the terminal should return the following message, as shown in the following screenshot:

Next, before installing Eclipse with PyDev, let's download Java 7 and JDK. To do this, we will add it to our system package repository and install Java. Open the terminal and type the following commands:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Be sure to use the keyboard keys on the licensing agreement in the terminal, as shown in the following screenshot:

When this is complete, you can test the installation by typing Java –version in the terminal. This command will return the installed version of Java.

Now, let's install Eclipse and PyDev. Navigate to http://www.eclipse.org/ using your browser of choice, and download Eclipse Classic. Unpack the download and open Eclipse, then select a workspace path, and click on OK.

Note

At the time of writing this, there is a bug for Eclipse's menus being reskinned in Ubuntu. If you're experiencing this issue, check online for a command-line fix, as this can vary between updates. Ubuntu 14.04 LTS is planned in order to have this bug resolved in the release.

Once this is done, open Eclipse Marketplace by navigating to Help | Eclipse Marketplace and search for PyDev. Install the plugin and agree to the certificate, then reboot Eclipse.

Assuming everything is installed properly, you'll see PyDev in the Preferences section of Eclipse.

One final note on Ubuntu: since Ubuntu has its own package manager, apt-get, we can install packages for Python using it as well, for example, using lxml:

sudo apt-get install python-lxml

Notice that we add a python- prefix before our package. This helps apt-get specify package types, since apt-get works with multiple languages.

At this point, you should be all set for the Python development. Try recreating our authorName script from our OS X and Windows sections.