Part 0: Setup

Initial setup for our Data Visualization Tutorial.

IMPORTANT: Please be sure to work through the machine setup before proceeding.
Need to cheat a bit? The complete Data Viz scripts can be found in new-coder/dataviz.

Change into the Data Viz project:

1
$ cd new-coder/dataviz

Make sure you’ve installed virtualenvwrapper and followed the steps from the machine setup to set up your terminal correctly. . To make a virtual environment specific to your Data Viz project, run the following command. You should see (DataVizProj) before your prompt.

1
2
$ mkvirtualenv DataVizProj
(DataVizProj)$
  • Now we will install the package requirements for this project. Your virtual environment will store the required packages in a self-contained area to not mess up with other Python projects.
1
(DataVizProj) $ pip install -r requirements.txt
NOTE: Sometimes, NumPy is finicky. If the previous step returns errors, try the following:

(DataVizProj)$ pip install numpy
(DataVizProj)$ pip install matplotlib
(DataVizProj)$ pip install geojson

Finicky matplotlib doesn’t install?

Sometimes, matplotlib is finicky as well. If you are on a Mac or Linux, and pip install matplotlib did not work, you are probably missing the supporting packages zlib, freetype2 and libpng. Windows users do not need to worry about this as these packages are already included in the standard matplotlib Windows installers.

To install (order of installation is important here):

ZLIB

  1. Go to zlib’s site and download the latest source code archive.
  2. Scroll down to zlib source code, and download the latest current release in tar.gz format
  3. Unpack the downloaded file by double-clicking to open it up.
  4. Open your terminal, and type as follows:
1
2
3
4
5
$ cd ~/Downloads  # or whichever directory the downloaded file was saved into
$ cd zlib-x.y.z  # whatever the version is you downloaded
$ ./configure
$ make
$ sudo make install

LIBPNG

  1. Navigate to the libpng site.
  2. Scroll down and download the latest version of libpng by clicking the tar.gz link on the Source Code row.
  3. Unpack the tar.gz file by double-clicking to open it up.
  4. Open your terminal, and type as follows:
1
2
3
4
5
6
$ cd ~/Downloads  # or whichever directory the downloaded file was saved into
$ cd libpng-x.y.z  # whatever the version is you downloaded
$ ./configure
$ make
$ make check
$ sudo make install

FREETYPE

  1. Navigate to freetype’s sourcforge page. The download of the source file should shart automatically.
  2. Unpack the file by double-clicking to open.
  3. Open your terminal, and type as follows:
1
2
3
4
5
$ cd ~/Downloads  # or whichever directory the downloaded file was saved into
$ cd freetype-x.y.z  # whatever the version is you downloaded
$ ./configure
$ make
$ sudo make install

After installing these three packages, try typing pip install matplotlib in your activated virtualenv, (DataVizProj) and it should work.

  • Test the installation real quick by starting up the Python interpreter:
1
2
3
4
(DataVizProj)$ python
>>> import numpy
>>> import matplotlib
>>> import geojson
  • If you have no errors (you would just see the >>> prompt), then you’re good to go. You can close out of the Python interpreter by pressing CTRL+D. If you do have errors, I’d try downloading numpy and matplotlib manually.