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

发布于 2024-07-17 11:04:35 字数 3558 浏览 7 评论 0原文

ft2build.h 位于此处:

C:\Program Files\GnuWin32\include

最初,我犯了与此处相同的错误:

致命错误 C1083:无法打开包含文件:“tiffio.h” :没有这样的文件或目录 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

梦萦几度 2024-07-24 11:04:35

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

sudo apt-get install python-dev libfreetype6-dev

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
生活了然无味 2024-07-24 11:04:35

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

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.

污味仙女 2024-07-24 11:04:35

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

brew install freetype

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

brew install freetype
茶花眉 2024-07-24 11:04:35

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

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.

椒妓 2024-07-24 11:04:35

由于这个错误,这个问题在 Google 中出现得很高,所以像其他几个问题一样,我将忽略它仅询问有关 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

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
随风而去 2024-07-24 11:04:35

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

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 2024-07-24 11:04:35

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

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)

一腔孤↑勇 2024-07-24 11:04:35

我还通过在 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

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.

甜妞爱困 2024-07-24 11:04:35

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

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

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
命比纸薄 2024-07-24 11:04:35

将文件下载到 C 盘上的文件夹中。
在 Windows CMD 提示符中,以管理员身份导航您的路径,使用
cd..cdwheels (在我的例子中,我将文件保存到 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

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
燃情 2024-07-24 11:04:35

我对 jetson nano (aarch64-linux-gnu) 也有同样的问题。 这对我有用 -

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文