1

尝试为 Python3 构建 matplotlib 时遇到以下错误。我已经安装了 Numpy 和 Scipy(包括调试扩展)。我还安装了 libpng12-0 和 libfreetype6 (和调试),但仍然没有。

运行后python3 setup.py build我得到以下信息:

running build_ext
building 'matplotlib.ft2font' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -DPYCXX_PYTHON_2TO3=1 -I/usr/local/include -I/usr/include -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/freetype2 -I/usr/local/include -I/usr/include -I. -I/usr/include/python3.2mu -c src/ft2font.cpp -o build/temp.linux-i686-3.2/src/ft2font.o
In file included from ./CXX/Extensions.hxx:37:0,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
./CXX/WrapPython.h:58:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

tom@dev-Optiplex:~/Downloads/matplotlib$ sudo find / -name "ft2font*"
/home/tom/Downloads/matplotlib/src/ft2font.cpp
/home/tom/Downloads/matplotlib/src/ft2font.h
tom@dev-Optiplex:~/Downloads/matplotlib$ 

我似乎无法理解它,因为它似乎无法找到 src/ft2font.* 文件,但是当我搜索它们时,它们肯定存在。我错过了什么?

谢谢!

4

1 回答 1

1

看起来您缺少 Python.h。你有安装 python3-dev 包吗?

指示是找不到的文件是Python.h.

In file included from ./CXX/Extensions.hxx:37:0,<-- (2) an include file in (1)
                 from src/ft2font.h:6,    <-- (1) an include file in (0)
                 from src/ft2font.cpp:3:  <-- (0) file gcc was trying to compile
./CXX/WrapPython.h:58:20: fatal error: Python.h: No such file or directory
  ^ (3) an include in (2) with error      ^ the actually missing file

Python.h是 python 的开发头文件。如果您不知道缺少的标头属于哪个包,您可以为您的发行版检查包装,其中大多数具有“按文件名搜索”功能。例如ubuntu 软件包列表

于 2013-02-06T15:10:00.810 回答