I am trying to install matplotlib in a new virtualenv.
When I do:
pip install matplotlib
or
pip install http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz
I get this error:
building 'matplotlib._png' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC - DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/include -I/usr/include -I. -I/home/sam/django-projects/datazone/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/include/python2.7 -c src/_png.cpp -o build/temp.linux-x86_64-2.7/src/_png.o
src/_png.cpp:10:20: fatal error: png.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Anyone have an idea what is going on?
Any help much appreciated.
To reduce the required packages to install you just need
and you will get the following packages locally installed
worked for me on Ubuntu 14.04
Building Matplotlib requires
libpng
(andfreetype
, as well) which isn't a python library, sopip
doesn't handle installing it (orfreetype
).You'll need to install something along the lines of
libpng-devel
andfreetype-devel
(or whatever the equivalent is for your OS).See the building requirements/instructions for matplotlib.
As I have struggled with this issue twice (even after fresh kubuntu 15.04 install) and installing freetype did not solve anything, I investigated further.
The solution:
From github issue:
After this installation proceeds smoothly.
To generate graph in png format you need to Install following dependent packages
Ubuntu https://apps.ubuntu.com/cat/applications/libpng12-0/ or using following command
None of the above answers worked for me in Mint, so I did: