ubuntu 14.04, pip cannot upgrade matplotllib

This is a known bug that has been fixed (https://github.com/matplotlib/matplotlib/pull/3414) on master.

The bug is in the handling of searching for a freetype installation. If you install the Linux package freetype-dev, you will avoid this bug and be able to compile matplotlib.

sudo apt-get install libfreetype6-dev

On Ubuntu 14 server, you also need to install libxft-dev

sudo apt-get install libfreetype6-dev libxft-dev

I had the same issues trying to install matplotlib on Python 3 using pip3, and it seems that this problem is related to a bare-bones installation of Python 3, and doing a:

sudo apt-get build-dep matplotlib

followed by

sudo pip3 install matplotlib 

is probably a better solution than selectively installing only the libraries related to matplotlib.