在Ubuntu16.04上安装PyQT5

时间:2018-11-11 08:54:24

标签: python pyqt5 ubuntu-16.04

我正在尝试使用Ubuntu16.04在我的PC中安装python-pyqt5。

当我像安装时一样

sudo apt install python-pyqt5

系统说,它已经安装了。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-pyqt5 is already the newest version (5.5.1+dfsg-3ubuntu4).
The following packages were automatically installed and are no longer required:
  libbotan-1.10-1 libclang1-3.6 libllvm3.6v5 libobjc-5-dev libobjc4
  libqbscore1 libqbsqtprofilesetup1 libqt4-designer libqt4-help libqt4-opengl
  libqt4-scripttools libqt4-svg libqt4-test libqt5concurrent5
  libqt5designercomponents5 libqt5quickwidgets5 libqt5script5
  libqt5xmlpatterns5 libqtassistantclient4 libqtwebkit4
  linux-headers-4.15.0-34 linux-headers-4.15.0-34-generic
  linux-image-4.15.0-34-generic linux-modules-4.15.0-34-generic
  linux-modules-extra-4.15.0-34-generic python-qt4 qml-module-qtquick-controls
  qtbase5-dev-tools qtcreator-data qtcreator-doc qttools5-dev-tools
  qtxmlpatterns5-dev-tools
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.

但是当我检查小麦时,我有PyQt5

>>from PyQt5.Qt import PYQT_VERSION_STR
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyQt5.Qt

系统说,我没有PyQt5的模块。

如何在我的Ubuntu16.04中安装PyQt5和QtCreator。

1 个答案:

答案 0 :(得分:0)

Ubuntu具有Python2和3。两种版本的模块都不同。

尝试安装pip和列表模块,以查看在任何一种安装中是否都存在。 如果您使用的是Python2:

sudo apt install python-pip
pip list

对于Python3:

sudo apt install python3-pip
pip3 list

如果您希望通过pip安装,则只需执行“ pip install PyQt”或“ pip3 install PyQt”。