编译PyQt5时出现致命错误:Python.h不存在

时间:2013-07-17 11:43:16

标签: python qt installation pyqt qt5

我正在尝试在我的Ubuntu 12.04盒子上安装PyQt5。因此,从here下载后,我解开了它,运行python configure.pymake。但是,请产生以下结果:

cd qpy/ && ( test -f Makefile || /opt/qt5/bin/qmake /home/kram/Downloads/PyQt-gpl-5.0/qpy/qpy.pro -o Makefile ) && make -f Makefile 
make[1]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy' is entered
cd QtCore/ && ( test -f Makefile || /opt/qt5/bin/qmake /home/kram/Downloads/PyQt-gpl-5.0/qpy/QtCore/QtCore.pro -o Makefile ) && make -f Makefile 
make[2]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy/QtCore' is entered
g++ -c -pipe -fno-strict-aliasing -O2 -Wall -W -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -I/opt/qt5/mkspecs/linux-g++ -I. -I. -I../../QtCore -I/usr/local/include/python2.7 -I/opt/qt5/include -I/opt/qt5/include/QtCore -I. -o qpycore_chimera.o qpycore_chimera.cpp
qpycore_chimera.cpp:21:20: fatal error: Python.h: File or folder does not exist
compilation terminated.
make[2]: *** [qpycore_chimera.o] Error 1
make[2]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy/QtCore' is left
make[1]: *** [sub-QtCore-make_first] Error 2
make[1]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy' is left
make: *** [sub-qpy-make_first-ordered] Error 2

(我将错误信息的某些部分从荷兰语翻译成英语,所以有些单词可能与正常的措辞相差一点......)

有人问题在这里吗?相关的Python.h文件在哪里?

4 个答案:

答案 0 :(得分:29)

问题是每个Makefile中所有python标头的include路径都将指向/usr/local/include/python2.7,这应该是/usr/include/python2.7

有两种可能的解决方案。您可以在每个Makefile中更改此项的所有匹配项,或者您可以创建指向该位置的符号链接

sudo ln -s /usr/include/python2.7 /usr/local/include/python2.7

现在您可以运行make

答案 1 :(得分:6)

sudo apt-get install python-dev

你错过了python头文件。

答案 2 :(得分:1)

你遇到的问题是PyQt假设你没有使用你发行版的托管python,而是默认在/usr/local/include/python2.7中寻找sip。

幸运的是,configure.py提供了覆盖python和sip包含位置的选项:

python configure.py --sip-incdir /usr/include/python2.7 py_inc_dir=/usr/include/python2.7

此解决方案应首选将/usr/include/python2.7符号链接到/usr/local/include/python2.7,因为这将使手动安装的软件能够污染(或损坏安装到的发行版包)发行版管理路径。

答案 3 :(得分:0)

最好将现有的头文件添加到QTCreator和Anjuta IDE中的项目目录中。