Score:2

Cannot run Spyder on Ubuntu (windows bash)

ch flag

I am very new to Linux and I am using Windows 11

installed ubuntu bash from MS store and installed Spyder using this command

sudo apt-get install spyder

But when I call Spyder

I get this error

user1@DELLG3:~$ spyder
qt.qpa.xcb: could not connect to display
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, xcb.

Aborted

I tried to uninstall and reinstall Spyder

but same error

any idea how to fix this?

ru flag
by 'Using Windows 11" and "Ubuntu (windows bash) do you mean WSL?
asmgx avatar
ch flag
yes i am using WSL
Score:5
cn flag

By default WSL doesn't have X-server, so you need to provide one. There are different X-servers available for Windows. Recently I read, on Windows 11 is available native application called WSLg.

Currently I'm on Windows 10 and really do like the third party app available on the Store called GWSL.

Jus install the application and launch it. Then click on its icon on the task bar, browse the list of Linux Apps and find your program - it should be Spider3.

enter image description here

Note on Windows 10 you must enable WSL2 if it's not enabled yet, I think it should be enabled by default on Windows 11.


In addition you could install a native X-server and entire desktop environment under WSL itself, then setup RDP service and use the Windows Remote Desktop application to log-in into the Ubuntu's desktop environment.

In my opinion, in most cases we do not need this far complicated solution. However here is a nice video tutorial how to do that, provided by David Bombal on YouTube: WSL2 Ubuntu GUI

Score:3
vn flag

I just tried this out on one of my "temporary" WSL2 Ubuntu instances, and I was able to get Spyder to run successfully under Windows 11.

There's definitely no need to install a third-party X server, as this works under WSLg without issue.

So a few things to try.

  • First, can you run other X applications? Make sure that echo $DISPLAY returns something like :0. Try a simple sudo apt install -y xterm && xterm. If that works, then you do have WSLg working.

  • If xterm doesn't work, make sure you have enabled WSLg. If you have upgraded from Windows 10 to Windows 11, you'll need to exit WSL, then:

    wsl --update
    wsl --shutdown
    

    Then try again.

  • Check to make sure you are running WSL2:

    wsl.exe -l -v
    

    If it shows version 1 for your instance, you'll need to update to WSL2. Let me know if that's the case, and I'll point you to directions for that.

  • Since you mention that you are fairly new to Linux, make sure that you have updated your repos so that you are obtaining the latest versions of all components:

    sudo apt update && sudo apt upgrade
    
  • Finally, if you previously followed some directions to modify $DISPLAY, examine your startup files (e.g. ~/.bashrc) and revert that. Make sure you are making no modifications manually to the DISPLAY variable in WSL under Windows 11.

Score:1
ng flag

I had the same error and it was NOT related to display or X-server.

First, you need to debug the output of spyder command:

export QT_DEBUG_PLUGINS=1
spyder
        Cannot load library /home/fer/miniconda3/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: cannot open shared object file: No such file or directory)
        QLibraryPrivate::loadPlugin failed on "/home/fer/miniconda3/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/fer/miniconda3/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-icccm.so.4: cannot open shared object file: No such file or directory)"
        Could not load the Qt platform plugin "xcb" in "" even though it was found.

Now you have found that is something related to libqxcb.so
Check that with ldd and you may found lots of not found libs:

ldd /home/fer/miniconda3/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so

Install apt-file so that you can check which packages provide those missing files (for instance):

    sudo apt install apt-file
    sudo apt-file update
    apt-file libxcb-icccm.so.4
    apt-file search libxcb-icccm.so.4
    apt-file search libxcb-util.so.1
    apt-file search libxcb-image.so.0
    apt-file search libxcb-keysyms.so.1
    apt-file search libxcb-render-util.so.0
    apt-file search libxcb-xkb.so.1
    apt-file search libxkbcommon-x11.so.0

After having the name of the packages, install then:

sudo apt-get install libxkbcommon-x11-0 libxcb-xkb1 libxcb-render-util0 libxcb-keysyms1 libxcb-image0 libxcb-util1 libxcb-icccm4

Now, you should be ok, or at least you should have cleaned the path to the next error :-)

This method of debugging may be used in several similar problems in the Linux world. Hope you enjoy it.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.