Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while installing matplotlib

I've tried using pip install matplotlib and git clone then python setup.py install as described in the installation faq for Mac OS 10.7. But I get the same error:

[...] llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I. -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/freetype2 -I./freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/ft2font.cpp -o build/temp.macosx-10.7-intel-2.7/src/ft2font.o cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ In file included from src/ft2font.cpp:3: src/ft2font.h:16:22: error: ft2build.h: No such file or directory src/ft2font.h:17:10: error: #include expects "FILENAME" or <FILENAME> src/ft2font.h:18:10: error: #include expects "FILENAME" or <FILENAME> src/ft2font.h:19:10: error: #include expects "FILENAME" or <FILENAME> src/ft2font.h:20:10: error: #include expects "FILENAME" or <FILENAME> src/ft2font.h:21:10: error: #include expects "FILENAME" or <FILENAME> In file included from src/ft2font.cpp:3: src/ft2font.h:34: error: ‘FT_Bitmap’ has not been declared src/ft2font.h:34: error: ‘FT_Int’ has not been declared src/ft2font.h:34: error: ‘FT_Int’ has not been declared src/ft2font.h:86: error: expected ‘,’ or ‘...’ before ‘&’ token [...] 

It seems like I'm missing some package installed in my system? Or there any other better way to install matplotlib?

Thanks!

UPDATE: by googling and search on SO I've found that I might lack the package freetype2, however, if I try to install it by homebrew I get a warning message:

[me @ my mac]$ brew search freetype Apple distributes freetype with OS X, you can find it in /usr/X11/lib. However not all build scripts look here, so you may need to call ENV.x11 in your formula's install function. 
like image 521
clwen Avatar asked Dec 02 '11 16:12

clwen


People also ask

Does Python 3.9 support matplotlib?

BUILDING MATPLOTLIB matplotlib: yes [3.3. 2] python: yes [3.9.

Why can I not import matplotlib?

Matplotlib is not a built-in module (it doesn't come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it. If you looking at how to install pip or if you are getting an error installing pip checkout pip: command not found to resolve the issue.

Does Python 3.7 support matplotlib?

Matplotlib is a python library that allows you to represent your data visually. It's particularly useful for data science and machine learning developers. Matplotlib is the most visualization package for Python.


1 Answers

I had this issue on Ubuntu server 12.04.

I had to install libfreetype6-dev and libpng-dev from the repositories. I was using a virtualenv and installing matplotlib using pip when I ran into this issue.

Hints that I needed to do this came from the warning messages that popup early in the matplotlib installation so keep an eye out for those messages which indicate a dependency is found, but not the headers.

like image 110
Javier Rosa Avatar answered Sep 22 '22 22:09

Javier Rosa