【问题标题】:Matplotlib Build Problem: Error C1083: Cannot open include file: 'ft2build.h'Matplotlib 构建问题:错误 C1083:无法打开包含文件:'ft2build.h'
【发布时间】:2010-10-20 05:21:37
【问题描述】:

ft2build.h 位于此处:

C:\Program Files\GnuWin32\include

一开始,我犯了和这里一样的错误:

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

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

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

【问题讨论】:

标签: python build matplotlib freetype


【解决方案1】:

在 Ubuntu 10.10 上构建 matplotlib 时也会出现此错误。解决办法是:

sudo apt-get install python-dev libfreetype6-dev

【讨论】:

  • OP 在 Windows 上,所以可能对他没有太大帮助,但 +1 帮助我在我的机器上解决这个问题。
  • 在 Ubuntu 20.4 上我还需要 pkg-config 包。
【解决方案2】:

您是否正确安装了freetype?如果有,安装目录下应该有一个名为ft2build.h 的文件,并且找到该文件的目录就是您应该用-I 指定的目录。字符串“GnuWin32”没有出现在构建命令的输出中,因此看起来您没有将该目录放在正确的包含列表中。

【讨论】:

  • 谢谢,我最终找到了 ft2build.h 并将其移动到我确定会包含在内的目录中。
  • 在 Windows 上考虑使用预构建的二进制文件。 This repository 的非官方二进制文件一直是我的救星。
【解决方案3】:

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

brew install freetype

【讨论】:

    【解决方案4】:

    我可以通过执行以下操作在 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。

    【讨论】:

      【解决方案5】:

      这个问题在谷歌中出现了这个错误,所以和其他几个问题一样,我会忽略它只询问 Windows 的事实。

      在 Debian 10 (Buster) 上我必须这样做:

      sudo apt install libfreetype6-dev pkg-config
      

      注意pkg-config 依赖;没有它,将安装 FreeType 标头,但 matplotlib 无法找到它们。它会在输出输出页面之前对此发出警告,因此很容易错过:

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

      【讨论】:

        【解决方案6】:

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

        【讨论】:

          【解决方案7】:

          我在red hat 6中遇到了同样的错误。原来我需要安装freetype-devel,而不是freetype(使用sudo yum install freetype-devel

          【讨论】:

            【解决方案8】:

            我还通过在 Mac OS X 上使用 homebrew 安装 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

            【讨论】:

              【解决方案9】:

              我花了几个小时试图让 matplotlib 安装最新的 python 3、pip、setuptools 一切......最终对我有用的是 https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib下载wheel文件并在同一目录下执行:

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

              【讨论】:

                【解决方案10】:

                将文件下载到 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
                

                【讨论】:

                  【解决方案11】:

                  我在使用 jetson nano (aarch64-linux-gnu) 时遇到了同样的问题。这对我有用-

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

                  【讨论】:

                    猜你喜欢
                    • 2020-02-29
                    • 2020-02-19
                    • 2014-12-07
                    • 2011-02-07
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多