Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found. in ubuntu 20.04

qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found. in ubuntu 20.04

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.3k 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.
  • M Offline
    M Offline
    mona
    wrote on 25 Jan 2021, 18:12 last edited by
    #1

    How should I solve this problem in Ubuntu 20.04?

    Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.xcb: could not connect to display :0
    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)
    Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.xcb: could not connect to display :0
    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)
    2224/31772MB(vision) 
    

    and

    $ echo $DISPLAY
    :0
    

    and

    $ python
    Python 3.8.5 (default, Jul 28 2020, 12:59:40)
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import inspect
    >>> from PyQt5 import Qt
    >>> vers = ['%s = %s' % (k,v) for k,v in vars(Qt).items() if k.lower().find('version') >= 0 and not inspect.isbuiltin(v)]
    >>> print('\n'.join(sorted(vers)))
    PYQT_VERSION = 331522
    PYQT_VERSION_STR = 5.15.2
    QOpenGLVersionProfile = <class 'PyQt5.QtGui.QOpenGLVersionProfile'>
    QOperatingSystemVersion = <class 'PyQt5.QtCore.QOperatingSystemVersion'>
    QT_VERSION = 331522
    QT_VERSION_STR = 5.15.2
    QVersionNumber = <class 'PyQt5.QtCore.QVersionNumber'>
    

    As a minimal code to reproduce this error, you can run this:

    $ cat test_qt.py 
    '''
    ====================
    3D plots as subplots
    ====================
    
    Demonstrate including 3D plots as subplots.
    '''
    
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d.axes3d import Axes3D, get_test_data
    from matplotlib import cm
    import numpy as np
    
    
    # set up a figure twice as wide as it is tall
    fig = plt.figure(figsize=plt.figaspect(0.5))
    
    #===============
    #  First subplot
    #===============
    # set up the axes for the first plot
    ax = fig.add_subplot(1, 2, 1, projection='3d')
    
    # plot a 3D surface like in the example mplot3d/surface3d_demo
    X = np.arange(-5, 5, 0.25)
    Y = np.arange(-5, 5, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
                           linewidth=0, antialiased=False)
    ax.set_zlim(-1.01, 1.01)
    fig.colorbar(surf, shrink=0.5, aspect=10)
    
    #===============
    # Second subplot
    #===============
    # set up the axes for the second plot
    ax = fig.add_subplot(1, 2, 2, projection='3d')
    
    # plot a 3D wireframe like in the example mplot3d/wire3d_demo
    X, Y, Z = get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
    
    plt.show()
    
    $ python test_qt.py 
    Invalid MIT-MAGIC-COOKIE-1 keyqt.qpa.xcb: could not connect to display :0
    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)
    
    $ qmake --version
    QMake version 3.1
    Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Jan 2021, 18:16 last edited by
      #2

      Hi and welcome to devnet,

      Please start your script with the QT_DEBUG_PLUGINS environment variable set to 1. It should give you more information about what is going on with the plugins.

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

      1 Reply Last reply
      1

      1/2

      25 Jan 2021, 18:12

      • Login

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