user92355
user92355

Reputation:

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

ft2build.h is located here:

C:\Program Files\GnuWin32\include

Initially, I made the same mistake as here:

Fatal Error C1083: Cannot Open Include file: 'tiffio.h': No such file or directory VC++ 2008

but since then, I've corrected that particular error (I've added the above directory to the "include" list, rather than the "executables" list), but I still get an error. The complete output is this:

BUILDING MATPLOTLIB
            matplotlib: 0.98.5.2
                python: 2.6.2 Stackless 3.1b3 060516 (release26-maint, Apr
                        14 2009, 21:19:36) [MSC v.1500 32 bit (Intel)]
              platform: win32
       Windows version: (5, 1, 2600, 2, 'Service Pack 3')

REQUIRED DEPENDENCIES
                 numpy: 1.3.0
             freetype2: found, but unknown version (no pkg-config)
                        * WARNING: Could not find 'freetype2' headers in any
                        * of '.', '.\freetype2'.

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
                        * Could not find 'libpng' headers in any of '.'
               Tkinter: no
                        * No tk/win32 support for this python version yet
              wxPython: 2.8.9.2
                        * WxAgg extension not required for wxPython >= 2.8
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: no
                    Qt: no
                   Qt4: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: no
                 latex: no
               pdftops: no

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.projections', 'mpl_to
olkits', 'matplotlib.numerix', 'matplotlib.numerix.mlab', 'matplotlib.numerix.ma
', 'matplotlib.numerix.npyma', 'matplotlib.numerix.linear_algebra', 'matplotlib.
numerix.random_array', 'matplotlib.numerix.fft', 'matplotlib.delaunay', 'pytz',
'dateutil', 'dateutil/zoneinfo']
running build
running build_py
copying lib\matplotlib\mpl-data\matplotlibrc -> build\lib.win32-2.6\matplotlib\m
pl-data
copying lib\matplotlib\mpl-data\matplotlib.conf -> build\lib.win32-2.6\matplotli
b\mpl-data
running build_ext
building 'matplotlib.ft2font' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W
3 /GS- /DNDEBUG -IC:\Python26\lib\site-packages\numpy\core\include -I. -IC:\Pyth
on26\lib\site-packages\numpy\core\include\freetype2 -I.\freetype2 -IC:\Python26\
include -IC:\Python26\include\Stackless -IC:\Python26\PC /Tpsrc/ft2font.cpp /Fob
uild\temp.win32-2.6\Release\src/ft2font.obj
ft2font.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
c:\python26\lib\site-packages\matplotlib-0.98.5.2\src\ft2font.h(13) : fatal erro
r C1083: Cannot open include file: 'ft2build.h': No such file or directory
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' fa
iled with exit status 2

I should mention that this is Python 2.6

Upvotes: 36

Views: 70198

Answers (11)

Thomas
Thomas

Reputation: 182028

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

Upvotes: 4

Avi Avidan
Avi Avidan

Reputation: 1106

I had the same issue with the jetson nano (aarch64-linux-gnu). this worked for me -

sudo apt-get install python-dev libfreetype6-dev
pip3 install --upgrade cyton
pip3 install matplotlib

Upvotes: 0

PaulisDontExcludeMe
PaulisDontExcludeMe

Reputation: 59

I spent hours trying to get matplotlib to install with the latest python 3, pip, setuptools everything... What finally worked for me was going to https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib downloading the wheel file and executing this in the same directory:

pip install matplotlib‑3.2.0rc2‑cp38‑cp38‑win_amd64.whl

Upvotes: 2

Steve Lynch
Steve Lynch

Reputation: 11

Download your file to a folder on your C drive. In windows CMD prompt as Administrator navigate you your path using cd.. or cd wheels (in my case I saved the file to c:\Wheels) then type pip install YourFilename.whl

Results in

Processing c:\wheels\scipy-0.19.0-cp27-cp27m-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in c:\python27\lib\site-packages (from scipy==0.19.0)
Installing collected packages: scipy
Successfully installed scipy-0.19.0

Upvotes: 0

Milean
Milean

Reputation: 888

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.

Upvotes: 4

user1496984
user1496984

Reputation: 11575

I also fixed this problem by installing freetype using homebrew on Mac OS X. However, that was not sufficient, as the libraries were not linked properly under Mac OS X 10.7. So I had to manually add them to pip command as follows:

brew install freetype
brew install libpng
LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" pip install matplotlib 

Note that you also have to add the folder /usr/local/opt/freetype/include/freetype2, which is not included by default on the homebrew notification, but will result in not finding ft2build.h.

Upvotes: 2

JoshNahum
JoshNahum

Reputation: 133

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

brew install freetype

Upvotes: 8

SaiyanGirl
SaiyanGirl

Reputation: 17034

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)

Upvotes: 3

Damien Farrell
Damien Farrell

Reputation: 729

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

Upvotes: 72

sa9
sa9

Reputation: 43

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.

Upvotes: 3

Jouni K. Seppänen
Jouni K. Seppänen

Reputation: 44142

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.

Upvotes: 14

Related Questions