Thursday, August 19, 2010

Matplotlib installing in a web server.

Matplotlib is the most complete 2d plotting package in Python you can find at the moment.
You will not encounter much problems installing and running matplotlib on a desktop but on a remote server, you might encounter problems, like missing or unconfigured tz packages.

So we will document installing from sources the matplotlib plotting package.

Step 1. Get the sources!
wget wget http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmatplotlib%2Ffiles%2F&ts=1282255399&mirror=nchc


Resolving downloads.sourceforge.net... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://surfnet.dl.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz [following]
--2010-08-19 22:11:56-- http://surfnet.dl.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz
Resolving surfnet.dl.sourceforge.net... 130.59.138.21, 2001:620:0:1b::21
Connecting to surfnet.dl.sourceforge.net|130.59.138.21|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12918842 (12M) [application/x-gzip]
Saving to: `matplotlib-1.0.0.tar.gz'

100%[==========================================================================================================================================>] 12,918,842 3.26M/s in 6.3s

2010-08-19 22:12:03 (1.95 MB/s) - `matplotlib-1.0.0.tar.gz' saved [12918842/12918842]

Step 2. Untar the package.

tar xzvvf matplotlib-1.0.0.tar.gz. This will create the matplotlib subdirectory.

Step 3. Install and test.

Cd to the matplotlib subdirectory and issue sudo python setup.py install
Don't be alarmed by the many C/C++ warnings you may see.
Now run python and import the matplotlib module. In my system, there are no errors.

I resorted to installing from sources after spending almost a half-day trying to do it from
apt-get and even from easy_install. I guess there are some destination directory mismatches!

Now if you get a display not defined error after installation, issue a export DISPLAY=:1.0, and reinstall again.

We will add our attempts to generate plots and graphs on a web server from matplotlib.
Stay tuned!

Finer details on the installation of matplotlib in a server environment with an example of generating a line graph: Please visit http://linux.byexamples.com/archives/404/python-generating-graphs-with-matplotlib/

No comments:

Post a Comment