代码之家  ›  专栏  ›  技术社区  ›  Emmanuel BRUNET

PyQt5-导入QtWidgets QtGui时出错

  •  2
  • Emmanuel BRUNET  · 技术社区  · 12 年前

    我运行的是Ubuntu 13.10(python--3.3.2+)。我安装了Qt5.2.1(linux安装程序)、SIP 4.15.5&PyQt5都来自官方网站的源代码。

    PyQt5版本:

    Qt qmake位于此处

    jeby6372@mercure:~$ ls /opt/Qt/5.2.1/gcc_64/bin
    assistant             qdbus           qml1plugindump    qmlviewer
    designer              qdbuscpp2xml    qml2puppet        qtpaths
    lconvert              qdbusviewer     qmlbundle         rcc
    linguist              qdbusxml2cpp    qmlimportscanner  syncqt.pl
    lrelease              qdoc            qmlmin            uic
    lupdate               qhelpconverter  qmlplugindump     xmlpatterns
    moc                   qhelpgenerator  qmlprofiler       xmlpatternsvalidator
    pixeltool             qmake           qmlscene
    qcollectiongenerator  qml             qmltestrunner
    

    我的python路径

    jeby6372@mercure:~$ echo $PYTHONPATH
    :/usr/lib/python3.3/site-packages
    

    Qt5库(出于显示目的而缩短列表):

    jeby6372@mercure:/opt/Qt/5.2.1/gcc_64/lib$ ls
    cmake                              libQt5Positioning.so.5
    libicudata.so.51                   libQt5Positioning.so.5.2
    libicudata.so.51.1                 libQt5Positioning.so.5.2.1
    libqgsttools_p.so                  libQt5PrintSupport.so.5.2.1
    libqgsttools_p.so.1                libQt5QmlDevTools.a
    libQt5CLucene.so.5.2               libQt5QuickParticles.so.5.2.1
    libQt5Concurrent.so.5.2            libQt5QuickTest.la
    libQt5Concurrent.so.5.2.1          libQt5QuickTest.prl
    libQt5Core.so.5.2.1                libQt5Script.prl
    libQt5DBus.la                      libQt5Script.so
    ....... 
    libQt5Multimedia.so                libQt5WebKit.prl
    libQt5Nfc.la                       libQt5Widgets.so.5.2.1
    libQt5Nfc.prl                      libQt5X11Extras.la
    libQt5Nfc.so                       libQt5X11Extras.prl
    libQt5Nfc.so.5                     libQt5X11Extras.so
    libQt5Nfc.so.5.2                   libQt5X11Extras.so.5
    libQt5OpenGLExtensions.a           libQt5X11Extras.so.5.2.1
    libQt5OpenGLExtensions.la          libQt5Xml.la
    libQt5OpenGL.so                    libQt5XmlPatterns.so.5
    libQt5OpenGL.so.5                  libQt5XmlPatterns.so.5.2
    libQt5OpenGL.so.5.2.1              libQt5Xml.prl
    libQt5Platfor
    libQt5PlatformSupport.prl          libQt5Xml.so.5.2
    libQt5Positioning.so
    

    我在从官方PyQt-gpl-5.2.1.tar.gz tarball中提取的源目录中运行了以下命令:

    python3 configure.py --qmake /opt/Qt/5.2.1/gcc_64/bin/qmake # My PyQt5 location
    sudo make
    sudo make install
    

    问题:

    我只能导入一组受限制的模块

    >>> from PyQt5.QtCore import *
    >>> from PyQt5.QtNetwork import *
    >>> from PyQt5.QtXmlPatterns import *
    >>> from PyQt5.Qt import *
    >>> from PyQt5.QtGui import *
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named 'PyQt5.QtGui'
    >>> from PyQt5.QtWidgets import *
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named 'PyQt5.QtWidgets'
    

    我可以导入QtCore、QtNetwork。。。如/usr/local/python3.3/sites-packages/PyQt5:

    jeby6372@mercure:/usr/lib/python3.3/site-packages/PyQt5$ ls
    __init__.py  QtCore.so  QtDBus.so  QtNetwork.so  Qt.so  QtXmlPatterns.so  uic
    

    但我无法导入QtWidgets、QtGui。。等等

    看来PyQt5库并没有全部复制到这里。

    同样的问题也在下面描述 post ……但不幸的是,RiverBanck团队没有回应:

    知道吗?

    1 回复  |  直到 12 年前
        1
  •  5
  •   Emmanuel BRUNET    12 年前

    缺少程序包

    按照mata的建议安装缺少的libgl1 mesa-dev依赖项。它是OpenGLAPI的免费实现。

    建筑

    sudo apt-get install libgl1-mesa-dev
    

    创建或清理PyQt5编译环境,并根据常规过程构建它。

    可供替代的

    如果此修复程序无法解决您的问题,请安装libgl1 mesa-glx包(glx运行时)和libgl1 mea-dri(绘图加速器)(如果它们也缺失),然后继续 建筑 说明书

    希望这能帮上忙。