以下是我的python,qt和sip版本

root@thura:~# python -V
Python 2.7.3
root@thura:~# qmake --version
QMake version 3.0
Using Qt version 5.0.2 in /usr/lib/i386-linux-gnu
root@thura:~# sip -V
4.15.3

我尝试通过跟随this导入PyQt5
from PyQt5.QtWidgets import QtGui, QtCore

我收到以下错误



我该如何解决这个错误。

更新=====================

当我尝试使用PyQt4时,出现以下错误。



2013年12月20日更新======================================



更新2013-12-20 =====================

重做一次之后。我收到以下错误
make[2]: Entering directory `/home/thura/PyQt/qpy/QtDBus'
make[2]: Nothing to be done for `install'.
make[2]: Leaving directory `/home/thura/PyQt/qpy/QtDBus'
make[1]: Leaving directory `/home/thura/PyQt/qpy'
cd QtCore/ && ( test -e Makefile || /usr/lib/i386-linux-gnu/qt5/bin/qmake /home/thura/PyQt/QtCore/QtCore.pro -o Makefile ) && make -f Makefile install
make[1]: Entering directory `/home/thura/PyQt/QtCore'
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DSIP_PROTECTED_IS_PUBLIC -Dprotected=public -DQT_NO_DEBUG -DQT_PLUGIN -DQT_CORE_LIB -I/usr/share/qt5/mkspecs/linux-g++ -I. -I/usr/local/include/python2.7 -I../qpy/QtCore -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I. -o sipQtCoreQtWindowStates.o sipQtCoreQtWindowStates.cpp
In file included from sipQtCoreQtWindowStates.cpp:24:0:
sipAPIQtCore.h:28:17: fatal error: sip.h: No such file or directory
compilation terminated.
make[1]: *** [sipQtCoreQtWindowStates.o] Error 1
make[1]: Leaving directory `/home/thura/PyQt/QtCore'
make: *** [sub-QtCore-install_subtargets-ordered] Error 2

最佳答案

如果您使用的是ubuntu,只需使用apt-get命令安装pyqt5:

    sudo apt-get install python3-pyqt5   # for python3

或者
    sudo apt-get install python-pyqt5    # for python2

但是,在Ubuntu 14.04上,python-pyqt5软件包被忽略[source],需要手动安装[source]

关于python - ImportError : No module named PytQt5,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20672918/

10-12 16:41
查看更多