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.
(going from the error messages only)
matplotlib requires libpng headers and libraries to be installed to
compile. You don't have (at least) the headers installed.
Not really related to django this, is it?
Cheers
Tom
No, the C compiler is entirely ignorant about virtualenv, they are
solely a python thing. You probably have libpng installed, but not
libpng-devel, which supplies the headers that allow programs to
compile against libpng*. Alternatively, you may not have libpng
installed at all...
Cheers
Tom
* Do Linux distros still do this? I use FreeBSD, so am not affected by
this madness. Why would an OS install a binary library and not install
the headers, the very thing that allow you to use the library
yourself. Madness.
At least ubuntu still does this.
Only reason I can think of is that it might be safer on the server or
something like that.
Reinout
--
Reinout van Rees http://reinout.vanrees.org/
rei...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"
One of virtualenv's options is to isolate you *completely* from the
system python. "virtualenv -s" or something like that.
Perhaps you passed along that option? In that case, nothing in your
virtualenv can find the system python's matplotlib.
I checked, it is '--no-site-packages'.
You can install matplotlib just fine in your virtualenv, but with one
prerequisite: all necessary libraries and header files must be available
for pip to be able to compile matplotlib.
This compiling-and-grabbing-headers stuff is already handled for you by
your OS and now you'll have to do it yourself. Which is fine, but it
*does* mean you must have all xyz-devel packages installed.
An alternative is to keep your global python clean and only install
specific packages with your OS that are best handled by the OS. Don't
"pip install" other stuff by hand.