To install the Python library matplotlib on a stock CentOS 5 system, you will need to resolve a freetype dependency issue prior to install. matplotlib 1.4.3 requires freetype ver >=2.3. CentOS 5's repositories top out at freetype 2.2.1.
To meet this dependency, download, compile and install a more recent version of freetype from here (this has been verified to work on a CentOS 5 system with freetype 2.4.0)
After downloading, do the usual unpack, configure, and make. Note that the default configuration will place the new freetype under /usr/local; for reference, the base CentOS install is under /usr.
Substitute the appropriate version of freetype below if not using 2.4.0
$ tar -xvf freetype-2.4.0.tar.gz
$ cd freetype-2.4.0
$ ./configure
$ make
$ sudo make install
Run to confirm:
$ freetype-config --ftversion
If /usr/local/bin is in your path and appears before /usr/bin, you should see
$ freetype-config --ftversion
2.4.0
(or whatever more recent version you downloaded) Then proceed to install matplotlib according to your preference, i.e.
$ pip install matplotlib
An alternative method to upgrading freetype is to install specific versions of numpy and matplotlib http://stackoverflow.com/questions/22076553/matplotlib-install-issues-pip-centos-freetype-missing-when-it-is-installed