Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQT5 could not load the Qt platform plugin “xcb”

PyQT5 could not load the Qt platform plugin “xcb”

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 4 Posters 5.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gurkirat Singh
    wrote on last edited by
    #1

    I am using the same code but with different libraries.

    The code with PyQt5

    import sys
    from PyQt5.QtWidgets import QApplication, QWidget
    
    if __name__ == '__main__':
    
        app = QApplication(sys.argv)
    
        w = QWidget()
        w.resize(250, 150)
        w.move(300, 300)
        w.setWindowTitle('Simple')
        w.show()
    
        sys.exit(app.exec_())
    

    The code with PySide2

    import sys
    from PySide2.QtWidgets import QApplication, QWidget
    
    if __name__ == '__main__':
    
        app = QApplication(sys.argv)
    
        w = QWidget()
        w.resize(250, 150)
        w.move(300, 300)
        w.setWindowTitle('Simple')
        w.show()
    
        sys.exit(app.exec_())
    

    The code works fine when using PySide2 but the following error comes when using PyQt5

    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
    
    Aborted (core dumped)
    

    PS: Trust me I have tried everything. Like reinstalling pyqt5 and qt5 framework

    OS: Linux h3ll 5.3.12-1-MANJARO #1 SMP PREEMPT Thu Nov 21 10:55:53 UTC 2019 x86_64 GNU/Linux
    QT Version: 5.12

    JonBJ 1 Reply Last reply
    0
    • G Gurkirat Singh

      I am using the same code but with different libraries.

      The code with PyQt5

      import sys
      from PyQt5.QtWidgets import QApplication, QWidget
      
      if __name__ == '__main__':
      
          app = QApplication(sys.argv)
      
          w = QWidget()
          w.resize(250, 150)
          w.move(300, 300)
          w.setWindowTitle('Simple')
          w.show()
      
          sys.exit(app.exec_())
      

      The code with PySide2

      import sys
      from PySide2.QtWidgets import QApplication, QWidget
      
      if __name__ == '__main__':
      
          app = QApplication(sys.argv)
      
          w = QWidget()
          w.resize(250, 150)
          w.move(300, 300)
          w.setWindowTitle('Simple')
          w.show()
      
          sys.exit(app.exec_())
      

      The code works fine when using PySide2 but the following error comes when using PyQt5

      qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
      This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
      
      Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
      
      Aborted (core dumped)
      

      PS: Trust me I have tried everything. Like reinstalling pyqt5 and qt5 framework

      OS: Linux h3ll 5.3.12-1-MANJARO #1 SMP PREEMPT Thu Nov 21 10:55:53 UTC 2019 x86_64 GNU/Linux
      QT Version: 5.12

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Gurkirat-Singh said in PyQT5 could not load the Qt platform plugin “xcb”:

      qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

      The first port of call for plugins is to run your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see what might go wrong when the plugin is loaded.

      It will come down to how you have installed PyQt vs PySide2, presumably. Compare your output with that environment variable set against, say:
      https://www.reddit.com/r/archlinux/comments/bzowkd/pyqt5_fails_to_load_could_not_load_the_qt/
      or
      https://bbs.archlinux.org/viewtopic.php?id=247030

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Denni-0 said in PyQT5 could not load the Qt platform plugin “xcb”:

        that and sys.exit(app.exec_( ) ) is the PyQt4 way to implement that line I have used the PyQt5 version below

        Can you show where it's specified that it does not apply to PyQt5 ?

        For example in the PyQt5 designer documentation, you have the classic:

        import sys
        from PyQt5.QtWidgets import QApplication, QDialog
        from ui_imagedialog import Ui_ImageDialog
        
        app = QApplication(sys.argv)
        window = QDialog()
        ui = Ui_ImageDialog()
        ui.setupUi(window)
        
        window.show()
        sys.exit(app.exec_())
        

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        JonBJ 1 Reply Last reply
        1
        • SGaistS SGaist

          @Denni-0 said in PyQT5 could not load the Qt platform plugin “xcb”:

          that and sys.exit(app.exec_( ) ) is the PyQt4 way to implement that line I have used the PyQt5 version below

          Can you show where it's specified that it does not apply to PyQt5 ?

          For example in the PyQt5 designer documentation, you have the classic:

          import sys
          from PyQt5.QtWidgets import QApplication, QDialog
          from ui_imagedialog import Ui_ImageDialog
          
          app = QApplication(sys.argv)
          window = QDialog()
          ui = Ui_ImageDialog()
          ui.setupUi(window)
          
          window.show()
          sys.exit(app.exec_())
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @SGaist
          I use sys.exit(app.exec()) [Python3] in PyQt5, works as expected across platforms. Not aware particularly of a change from PyQt4 to PyQt5, same behaviour.

          1 Reply Last reply
          0
          • JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @Denni-0 , @SGaist
            So far as I am aware, there is no difference in behaviour from PyQt4 to PyQt5 with regard to sys.exit(app.exec()).

            If you choose not to use sys.exit(app.exec()) but just app.exec() in PyQt5 as you say, could you please explain how you return a process exit code to any caller which is interested in it? Of course you have always been able to omit the sys.exit() in either PyQt4 or PyQt5, it's just that then you cannot control the exit code. That is the reason sys.exit() has always been used....

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved