Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib Build Problem: Error C1083: Cannot open include file: 'ft2build.h'

This error comes about when building matplotlib on Ubuntu 10.10 also. The solution is to do:

sudo apt-get install python-dev libfreetype6-dev

Have you installed freetype properly? If you have, there should be a file named ft2build.h somewhere under the installation directory, and the directory where that file is found is the one that you should specify with -I. The string "GnuWin32" does not appear anywhere in the output of your build command, so it looks like you have not placed that directory in the correct include list.


Another solution for Mac OS X is to install Freetype with Homebrew.

brew install freetype

I was able to solve this on Windows by doing the following:

   set INCLUDE=%INCLUDE%;C:\tmp\msvcr90-x32
   set LIB=%LIB%;C:\tmp\msvcr90-x32
   pip.exe install matplotlib

The link libraries for Freetype on windows can be found here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib (from meawoppl's comment)

Just download the "matplotlib‑1.x‑windows‑link‑libraries.zip", and open the README from the zip.


For those who might have the same issue but on a Mac OS 10.6 (snow leopard) and Python 2.7. , the easiest solution I found was to get a make file which downloads Numpy, scipy and matplotlib and compile them for you. You can customize the make file to get you matplotlib only. Here is the link to the solution.


I had the same error in red hat 6. Turns out that I needed to install freetype-devel, not freetype (using sudo yum install freetype-devel)


This question comes up high in Google for this error, so like several others I'll ignore the fact that it's asking about Windows only.

On Debian 10 (Buster) I had to do:

sudo apt install libfreetype6-dev pkg-config

Note the pkg-config dependency; without it, the FreeType headers get installed, but matplotlib is unable to find them. It warns about this before spitting out pages of output, so it's easy to miss:

IMPORTANT WARNING:
    pkg-config is not installed.
    matplotlib may not be able to find some of its dependencies