尝试为Python3构建matplotlib时遇到以下错误。我已经安装了Numpy和Scipy(包括调试扩展)。我还安装了libpng12-0和libfreetype6(和debug),但仍然没有。
运行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。*文件,但是当我搜索它们时,它们肯定存在。我错过了什么?
谢谢!
答案 0 :(得分: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的dev头。如果您不知道丢失的标题所属的包,您可以检查发行版的包装,其中大多数都有“按文件名搜索”功能。前the ubuntu package listing。