本文介绍了ImportError:没有名为 PytQt5 的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

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

following are my python, qt and sip versions

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

from PyQt5.QtWidgets import QtGui, QtCore

我收到以下错误

ImportError: No module named PyQt5.QtWidgets

我该如何解决这个错误.

How can I solve this error.

更新了======================

Updated =====================

当我尝试 PyQt4 时,出现以下错误.

When I tried to PyQt4, I got following error.

from PyQt4.QtCore import pyqtSlot as Slot RuntimeError: the sip模块实现 API v10.0 到 v10.1 但 PyQt4.QtCore 模块需要 API v8.1

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

Updated 2013-12-20 ======================================

1) 从这里

2) 提取 sip-4.15.3.tar.gz

2) extract sip-4.15.3.tar.gz

3) 复制 sip-4.15.3 到/home/thura

3) copy sip-4.15.3 to /home/thura

4) 键入cd/home/thura/sip-4.15.3"

4) type "cd /home/thura/sip-4.15.3"

5) 键入python configure.py",按回车,按照说明操作(输入 yes 并回车)

5) type "python configure.py", press enter, follow the instructions (type yes and press enter)

6) 输入make",回车,输入make install",回车

6) type "make", press enter and type "make install", press enter

7) 从这里

8) 提取 PyQt-gpl-5.1.1.tar.gz

8) extract PyQt-gpl-5.1.1.tar.gz

9) 将 PyQt-gpl-5.1.1 文件夹复制到/home/thura 文件夹.

9) copy PyQt-gpl-5.1.1 folder to /home/thura folder.

10) 键入cd/home/thura/PyQt-gpl-5.1.1"

10) type "cd /home/thura/PyQt-gpl-5.1.1"

11) 键入python configure.py",按回车,跟随说明(输入 yes 并回车)

11) type "python configure.py", press enter, following the instructions (type yes and press enter)

12)输入make",回车,输入make install",回车

12)type "make", press enter and type "make install", press enter

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

update 2013-12-20 =====================

重做一遍后.我收到以下错误

After redo it again. I got the following error

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:

If you are on ubuntu, just install pyqt5 with apt-get command:

    sudo apt-get install python3-pyqt5   # for python3

    sudo apt-get install python-pyqt5    # for python2

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

However, on Ubuntu 14.04 the python-pyqt5 package is left out [source] and need to be installed manually [source]

这篇关于ImportError:没有名为 PytQt5 的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 20:51