PyQt5错误:此应用程序无法启动,因为它找不到或加载Qt平台插件“ xcb”

时间:2019-08-27 15:06:08

标签: python python-3.x pyqt5

我将PyQt4升级到PyQt5,并使用python3。我有以下进口商品:

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

我有以下主要内容:

if __name__ == "__main__":
    # Get parameters
    print("HERE1")
    opts = monGetOpts()
    print("HERE2")
    # Set exceptions and signals handling
    sys.excepthook = monExceptionsHandler
    print("HERE3")
    signal(SIGINT, monSignalsHandler)
    print("HERE4")
    # Launch GUI
    print(sys.argv)
    app = QApplication(sys.argv)
    print("HERE5\n")
    style = QStyleFactory.create('windows')
    print("HERE6\n")
    app.setStyle(style)
    myMonitor = MyMonitor(opts['workdir'], opts['refresh'])
    myMonitor.show()
    app.exec_()

我添加了照片以跟踪错误的来源并显示错误:

HERE1
HERE2
HERE3
HERE4
['./mon.py', '-w', '/path/to/work_dir/']
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.

Reinstalling the application may fix this problem.
Abort

我看到有很多有关此问题的线程,但是他们建议使用Linux ldd命令,但不确定是否与此相关。 我认为它来自PyQt5,因为它可以与PyQt4一起使用。可能是什么问题?

编辑:我在ldd文件上使用了libqxcb.so。输出:

linux-vdso.so.1 (0x00007ffff7ffa000)
libQt5XcbQpa.so.5 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5XcbQpa.so.5 (0x00007ffff783f000)
libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007ffff7601000)
libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007ffff7365000)
libz.so.1 => /lib64/libz.so.1 (0x00007ffff714f000)
libQt5Gui.so.5 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5Gui.so.5 (0x00007ffff6926000)
libQt5DBus.so.5 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5DBus.so.5 (0x00007ffff669a000)
libQt5Core.so.5 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5Core.so.5 (0x00007ffff5f07000)
libGL.so.1 => /usr/lib64/libGL.so.1 (0x00007ffff5c9d000)
libpthread.so.0 => /lib64/noelision/libpthread.so.0 (0x00007ffff5a80000)
libX11-xcb.so.1 => /usr/lib64/libX11-xcb.so.1 (0x00007ffff587e000)
libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007ffff565e000)
libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00007ffff5454000)
libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007ffff5242000)
libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007ffff4f04000)
libm.so.6 => /lib64/libm.so.6 (0x00007ffff4c07000)
libxkbcommon-x11.so.0 => /usr/lib64/libxkbcommon-x11.so.0 (0x00007ffff49ff000)
libxkbcommon.so.0 => /usr/lib64/libxkbcommon.so.0 (0x00007ffff47c0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ffff45bc000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007ffff4232000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ffff401a000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffff3c75000)
libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007ffff3a73000)
libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007ffff3763000)
libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007ffff3539000)
libbz2.so.1 => /usr/lib64/libbz2.so.1 (0x00007ffff332a000)
libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007ffff30ed000)
libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007ffff2ea6000)
libicui18n.so.56 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libicui18n.so.56 (0x00007ffff2a0d000)
libicuuc.so.56 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libicuuc.so.56 (0x00007ffff2655000)
libicudata.so.56 => /usr/pkgs/python3/3.6.3/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libicudata.so.56 (0x00007ffff0c72000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffff7ddb000)
libxcb-dri3.so.0 => /usr/lib64/libxcb-dri3.so.0 (0x00007ffff0a6f000)
libxcb-present.so.0 => /usr/lib64/libxcb-present.so.0 (0x00007ffff086c000)
libxcb-sync.so.1 => /usr/lib64/libxcb-sync.so.1 (0x00007ffff0666000)
libxshmfence.so.1 => /usr/lib64/libxshmfence.so.1 (0x00007ffff0463000)
libglapi.so.0 => /usr/lib64/libglapi.so.0 (0x00007ffff0235000)
libXdamage.so.1 => /usr/lib64/libXdamage.so.1 (0x00007ffff0032000)
libXfixes.so.3 => /usr/lib64/libXfixes.so.3 (0x00007fffefe2c000)
libxcb-glx.so.0 => /usr/lib64/libxcb-glx.so.0 (0x00007fffefc14000)
libxcb-dri2.so.0 => /usr/lib64/libxcb-dri2.so.0 (0x00007fffefa0f000)
libXxf86vm.so.1 => /usr/lib64/libXxf86vm.so.1 (0x00007fffef809000)
libdrm.so.2 => /usr/lib64/libdrm.so.2 (0x00007fffef5fa000)
libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fffef3f6000)
libxcb-xkb.so.1 => /usr/lib64/libxcb-xkb.so.1 (0x00007fffef1db000)
libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007fffeef6c000)

第二编辑

我将QT_DEBUG_PLUGINS设置为1,然后重新运行代码并得到:

QFactoryLoader::QFactoryLoader() checking directory path "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms" ...                                                                                                                                       
QFactoryLoader::QFactoryLoader() looking at "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqeglfs.so"                                                                                                                                           
Found metadata in lib /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqeglfs.so, metadata=                                                                                                                                                        
{                                                                                                                                                           
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",                                                                                
    "MetaData": {                                                                                                                                           
        "Keys": [                                                                                                                                           
            "eglfs"                                                                                                                                         
        ]                                                                                                                                                   
    },                                                                                                                                                      
    "className": "QEglFSIntegrationPlugin",                                                                                                                 
    "debug": false,                                                                                                                                         
    "version": 329473                                                                                                                                       
}                                                                                                                                                           


Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqlinuxfb.so"                                                                                                                                         
Found metadata in lib /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqlinuxfb.so, metadata=                                                                                                                                                      
{                                                                                                                                                           
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",                                                                                
    "MetaData": {                                                                                                                                           
        "Keys": [                                                                                                                                           
            "linuxfb"                                                                                                                                       
        ]                                                                                                                                                   
    },                                                                                                                                                      
    "className": "QLinuxFbIntegrationPlugin",                                                                                                               
    "debug": false,                                                                                                                                         
    "version": 329473                                                                                                                                       
}                                                                                                                                                           


Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqminimal.so"                                                                                                                                         
Found metadata in lib /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqminimal.so, metadata=                                                                                                                                                      
{                                                                                                                                                           
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",                                                                                
    "MetaData": {                                                                                                                                           
        "Keys": [                                                                                                                                           
            "minimal"                                                                                                                                       
        ]                                                                                                                                                   
    },                                                                                                                                                      
    "className": "QMinimalIntegrationPlugin",                                                                                                               
    "debug": false,                                                                                                                                         
    "version": 329473                                                                                                                                       
}                                                                                                                                                           


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqminimalegl.so"                                                                                                                                      
Found metadata in lib /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqminimalegl.so, metadata=                                                                                                                                                   
{                                                                                                                                                           
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",                                                                                
    "MetaData": {                                                                                                                                           
        "Keys": [                                                                                                                                           
            "minimalegl"                                                                                                                                    
        ]                                                                                                                                                   
    },                                                                                                                                                      
    "className": "QMinimalEglIntegrationPlugin",                                                                                                            
    "debug": false,                                                                                                                                         
    "version": 329473                                                                                                                                       
}                                                                                                                                                           


Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqoffscreen.so"                                                                                                                                       
Found metadata in lib /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqoffscreen.so, metadata=                                                                                                                                                    
{                                                                                                                                                           
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",                                                                                
    "MetaData": {                                                                                                                                           
        "Keys": [                                                                                                                                           
            "offscreen"                                                                                                                                     
        ]
    },
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 329473
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 329473
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/pkgs/python3/3.6.3a/bin/platforms" ...
Cannot load library /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libEGL.so.1: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /usr/pkgs/python3/3.6.3a/modules/r1/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libEGL.so.1: cannot open shared object file: No such file or directory)"
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.

Reinstalling the application may fix this problem.
Abort

我无法重新安装该库,必须使用IT给我们的东西。我们需要使用xcb吗?也许以某种方式将其替换为其他可用平台? 操作系统是Linux SLES12

0 个答案:

没有答案