Install with pip
pip install matplotlib
# or
pip3 install matplotlib
#or
sudo apt-get build-dep python-matplotlib
# or
git clone git://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py install
Check if it works
python2 -c ‘import matplotlib; print matplotlib.version, matplotlib.file‘
python3 -c ‘import matplotlib; print(matplotlib.version, matplotlib.file)’
“`