首页 文章

Matplotlib构建问题:错误C1083:无法打开包含文件:'ft2build.h'

提问于
浏览
26

ft2build.h 位于:

C:\Program Files\GnuWin32\include

最初,我犯了同样的错误:

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

但从那时起,我已经纠正了这个特定的错误(我已将上面的目录添加到“include”列表,而不是“可执行文件”列表),但我仍然收到错误 . 完整的输出是这样的:

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

我应该提一下,这是Python 2.6

8 回答

  • 3

    你是否正确安装了freetype?如果有,则在安装目录下的某处应该有一个名为 ft2build.h 的文件,找到该文件的目录是您应该使用 -I 指定的目录 . 字符串"GnuWin32"不会出现在构建命令的输出中的任何位置,因此看起来您没有将该目录放在正确的包含列表中 .

  • 2

    在Ubuntu 10.10上构建matplotlib时也会出现此错误 . 解决方案是:

    sudo apt-get install python-dev libfreetype6-dev
    
  • 0

    Mac OS X的另一个解决方案是使用Homebrew安装Freetype .

    brew install freetype
    
  • 2

    对于那些可能在Mac OS 10.6(雪豹)和Python 2.7上有相同问题的人 . ,我找到的最简单的解决方案是获取一个make文件,下载Numpy,scipy和matplotlib并为你编译它们 . 您可以自定义make文件以仅为matplotlib . 这是解决方案的link .

  • 14

    我在红帽子中遇到了同样的错误6.结果我需要安装 freetype-devel ,而不是 freetype (使用 sudo yum install freetype-devel

  • 60

    我还通过在Mac OS X上使用自制软件安装freetype来解决这个问题 . 但是,这还不够,因为在Mac OS X 10.7下没有正确链接库 . 所以我不得不手动将它们添加到 pip 命令,如下所示:

    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
    

    请注意,您还必须添加文件夹 /usr/local/opt/freetype/include/freetype2 ,默认情况下不包含在自制程序通知中,但会导致找不到 ft2build.h .

  • 3

    通过执行以下操作,我能够在Windows上解决此问题:

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

    Windows上的Freetype链接库可以在这里找到:http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib(来自meawoppl的评论)

    只需下载“matplotlib-1.x-windows-link-libraries.zip”,然后从zip打开README .

  • 7

    将文件下载到C驱动器上的文件夹中 . 在Windows CMD提示符管理员使用 cd..cd wheels 导航您的路径(在我的情况下,我将文件保存到 c:\Wheels )然后键入 pip install YourFilename.whl

    结果是

    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
    

相关问题