mne browse_raw does not use qt backend

I have two user accounts on a Windows computer each using a Linux WSL shell. One can use the command line tool mne browse_raw the other one runs and quits without opening a the plot window:

$ mne browse_raw sub-001_desc-Filt_eeg.fif
Opening raw data file sub-001_desc-Filt_eeg.fif...
    Range : 0 ... 753964 =      0.000 ...  3015.856 secs
Ready.
Using matplotlib as 2D backend.

But it does open from a notebook in VSCode using qt…

Here’s the sys_info for the one that works:

Platform             Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python               3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]
Executable           /home/moberg/mne-python/1.6.0_0/bin/python3.11
CPU                  x86_64 (20 cores)
Memory               15.5 GB

Core
β”œβ˜’ mne               1.6.0 (outdated, release 1.6.1 is available!)
β”œβ˜‘ numpy             1.26.0 (OpenBLAS 0.3.24 with 20 threads)
β”œβ˜‘ scipy             1.11.3
β”œβ˜‘ matplotlib        3.8.2 (backend=QtAgg)
β”œβ˜‘ pooch             1.8.0
β””β˜‘ jinja2            3.1.2

Numerical (optional)
β”œβ˜‘ sklearn           1.3.2
β”œβ˜‘ numba             0.58.1
β”œβ˜‘ nibabel           5.1.0
β”œβ˜‘ nilearn           0.10.2
β”œβ˜‘ dipy              1.7.0
β”œβ˜‘ openmeeg          2.5.7
β”œβ˜‘ pandas            2.1.3
β””β˜ unavailable       cupy

Visualization (optional)
β”œβ˜‘ pyvista           0.42.3 (OpenGL 4.2 (Core Profile) Mesa 23.0.4-0ubuntu1~22.04.1 via D3D12 (NVIDIA GeForce RTX 3060))
β”œβ˜‘ pyvistaqt         0.11.0
β”œβ˜‘ vtk               9.2.6
β”œβ˜‘ qtpy              2.4.1 (PySide6=6.6.1)
β”œβ˜‘ ipympl            0.9.3
β”œβ˜‘ pyqtgraph         0.13.3
β”œβ˜‘ mne-qt-browser    0.6.1
β”œβ˜‘ ipywidgets        8.1.1
β”œβ˜‘ trame_client      2.12.6
β”œβ˜‘ trame_server      2.12.1
β”œβ˜‘ trame_vtk         2.6.2
β””β˜‘ trame_vuetify     2.3.1

Ecosystem (optional)
β”œβ˜‘ mne-bids          0.14
β”œβ˜‘ mne-nirs          0.6.0
β”œβ˜‘ mne-features      0.3
β”œβ˜‘ mne-connectivity  0.5.0
β”œβ˜‘ mne-icalabel      0.5.1
β””β˜‘ mne-bids-pipeline 1.4.0

And the one that doesn’t:

(mne-1.6.1_0) user@SASS-161:~/DWD$ mne sys_info
Platform             Linux-4.4.0-19041-Microsoft-x86_64-with-glibc2.35
Python               3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]
Executable           /home/user/mne-python/1.6.1_0/bin/python3.11
CPU                  x86_64 (20 cores)
Memory               31.7 GB

Core
β”œβ˜‘ mne               1.6.1 (latest release)
β”œβ˜‘ numpy             1.26.3 (OpenBLAS 0.3.25 with 20 threads)
β”œβ˜‘ scipy             1.11.4
β”œβ˜‘ matplotlib        3.8.2 (backend=agg)
β”œβ˜‘ pooch             1.8.0
β””β˜‘ jinja2            3.1.3

Numerical (optional)
β”œβ˜‘ sklearn           1.3.2
β”œβ˜‘ numba             0.58.1
/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/numpy/core/getlimits.py:542: UserWarning: Signature b'\x00\xd0\xcc\xcc\xcc\xcc\xcc\xcc\xfb\xbf\x00\x00\x00\x00\x00\x00' for <class 'numpy.longdouble'> does not match any known type: falling back to type probe function.
This warnings indicates broken support for the dtype!
  machar = _get_machar(dtype)
β”œβ˜‘ nibabel           5.2.0
β”œβ˜‘ nilearn           0.10.2
β”œβ˜‘ dipy              1.7.0
β”œβ˜‘ openmeeg          2.5.7
β”œβ˜‘ pandas            2.1.4
β””β˜ unavailable       cupy

Visualization (optional)
β”œβ˜‘ pyvista           0.43.2 (OpenGL unavailable)
β”œβ˜‘ qtpy              2.4.1 (None=None)
β”œβ˜‘ ipympl            0.9.3
β”œβ˜‘ mne-qt-browser    0.6.1
β”œβ˜‘ ipywidgets        8.1.1
β”œβ˜‘ trame_client      2.14.2
β”œβ˜‘ trame_server      2.15.0
β”œβ˜‘ trame_vtk         2.7.0
β”œβ˜‘ trame_vuetify     2.3.1
β””β˜ unavailable       pyvistaqt, vtk, pyqtgraph

Ecosystem (optional)
β”œβ˜‘ mne-bids          0.14
β”œβ˜‘ mne-nirs          0.6.0
β”œβ˜‘ mne-features      0.3
β”œβ˜‘ mne-connectivity  0.6.0
β”œβ˜‘ mne-icalabel      0.6.0
β””β˜‘ mne-bids-pipeline 1.5.0

It looks like I have qt on the installation that’s not working, but it’s just not being used. How do I get the qt backend invoked from the command line? There’s nothing about that in the docs

Try mne.viz.set_browser_backend

The broken one says:

indicating that no Qt binding framework was found (should say β€œPyside6=X.Y.Z” or β€œPyQt6=X.Y.Z”). Something like pip install pyqt6 or pip install PySide6 (one or the other, not both!) might fix it.

Thanks @drammock . This has been a bit of a rabbit hole!

Installing PySide6 didn’t work – silent exit and same output in sys_info. I then uninstalled PySide6 and installed pyqt6 with the same null result.

I then made sure the plots show when in VScode, which they do. Here’s mne.sys_info()

Platform             Windows-10-10.0.19045-SP0
Python               3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:23:48) [MSC v.1936 64 bit (AMD64)]
Executable           c:\Users\user\mne-python\1.6.0_0\python.exe
CPU                  Intel64 Family 6 Model 151 Stepping 2, GenuineIntel (20 cores)
Memory               31.7 GB

Core
β”œβ˜’ mne               1.6.0 (outdated, release 1.6.1 is available!)
β”œβ˜‘ numpy             1.26.0 (OpenBLAS 0.3.24 with 20 threads)
β”œβ˜‘ scipy             1.11.3
β”œβ˜‘ matplotlib        3.8.2 (backend=module://matplotlib_inline.backend_inline)
β”œβ˜‘ pooch             1.8.0
β””β˜‘ jinja2            3.1.2

Numerical (optional)
β”œβ˜‘ sklearn           1.3.2
β”œβ˜‘ numba             0.58.1
β”œβ˜‘ nibabel           5.1.0
β”œβ˜‘ nilearn           0.10.2
β”œβ˜‘ dipy              1.7.0
β”œβ˜‘ openmeeg          2.5.7
β”œβ˜‘ pandas            2.1.3
β””β˜ unavailable       cupy

Visualization (optional)
β”œβ˜‘ pyvista           0.42.3 (OpenGL 4.5.0 NVIDIA 517.02 via NVIDIA GeForce RTX 3060/PCIe/SSE2)
β”œβ˜‘ pyvistaqt         0.11.0
β”œβ˜‘ vtk               9.2.6
β”œβ˜‘ qtpy              2.4.1 (PyQt5=5.15.8)
β”œβ˜‘ ipympl            0.9.3
β”œβ˜‘ pyqtgraph         0.13.3
β”œβ˜‘ mne-qt-browser    0.6.1
β”œβ˜‘ ipywidgets        8.1.1
β”œβ˜‘ trame_client      2.12.6
β”œβ˜‘ trame_server      2.12.1
β”œβ˜‘ trame_vtk         2.6.2
β””β˜‘ trame_vuetify     2.3.1

Ecosystem (optional)
β”œβ˜‘ mne-bids          0.14
β”œβ˜‘ mne-nirs          0.6.0
β”œβ˜‘ mne-features      0.3
β”œβ˜‘ mne-connectivity  0.5.0
β”œβ˜‘ mne-icalabel      0.5.1
β””β˜‘ mne-bids-pipeline 1.4.0

It’s using PyQt 5.15.8

Maybe this is an issue with the command line tools for the linux installation? Which would be odd since it works on the linux WSL on the other account… I tried @wmvanvliet suggestion of running a script with set_browser_backen('qt') . That lead to this traceback:

    mne.viz.set_browser_backend('qt')
  File "<decorator-gen-425>", line 12, in set_browser_backend
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne/viz/_figure.py", line 774, in set_browser_backend
    _load_backend(backend_name)
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne/viz/_figure.py", line 651, in _load_backend
    from mne_qt_browser import _pg_figure as backend
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne_qt_browser/_pg_figure.py", line 47, in <module>
    from qtpy.QtGui import (
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/qtpy/QtGui.py", line 45, in <module>
    from PyQt5.QtGui import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

That led me to install libgl apt install libgl1 but now when selecting the qt backend a display can’t be found:

File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne/io/base.py", line 1808, in plot
    return plot_raw(
           ^^^^^^^^^
  File "<decorator-gen-180>", line 12, in plot_raw
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne/viz/raw.py", line 405, in plot_raw
    fig = _get_browser(show=show, block=block, **params)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne/viz/_figure.py", line 698, in _get_browser
    fig = backend._init_browser(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne_qt_browser/_pg_figure.py", line 5177, in _init_browser
    out = _init_mne_qtapp(pg_app=True, **app_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/mne-python/1.6.1_0/lib/python3.11/site-packages/mne/viz/backends/_utils.py", line 161, in _init_mne_qtapp
    raise RuntimeError("Cannot connect to a valid display")
RuntimeError: Cannot connect to a valid display

I understand this is really getting into the weeds – likely due to some difference in WSL installations. Working on the windows shell might be easier.

at this point my approach would probably be to start over with a fresh virtual environment. I didn’t mention it before, but I also noticed in the β€œbad” sysinfo that right after Numba you get:

…which is another reason to consider starting over with a new env. It’s a bilt annoying since your sys_info shows you have many extra things installed that our environment.yml file won’t pull in automatically (connectivity, nirs, features, bids-pipeline, etc). But fixing numpy incompatibilities after they arise can take some detective work, as can fixing Qt incompatibilities (as you’ve demonstrated!) There’s nothing wrong with resigning onesself to not knowing what exactly went wrong, and starting with a clean slate.

1 Like

Thank you for the reply @drammock . The (funny) thing is, is that the broken environment is on a fresh install – which has me worried that I’ve done something to my other environment that I’ve forgotten about! I have a workaround for now so I’m going to postpone digging further into this for awhile.

So I think my original problem had to do with running WSL on windows 10. Windows 11 seems to have better GUI support with WSLg, but that’s the extent of my knowledge there…

I upgraded to windows 11, did a fresh install of wsl2 Ubuntu, MNE with the linux installer, and plotting from command line scripts fell back to using matplotlib. Here’s a partial sys_info:

Visualization (optional)
β”œβ˜‘ pyvista           0.42.3 (OpenGL unavailable)
β”œβ˜‘ qtpy              2.4.1 (None=None)
β”œβ˜‘ ipympl            0.9.3
β”œβ˜‘ mne-qt-browser    0.6.1
β”œβ˜‘ ipywidgets        8.1.1
β”œβ˜‘ trame_client      2.12.6
β”œβ˜‘ trame_server      2.12.1
β”œβ˜‘ trame_vtk         2.6.2
β”œβ˜‘ trame_vuetify     2.3.1
β””β˜ unavailable       pyvistaqt, vtk, pyqtgraph

I installed a qt library:
sudo apt install libgl1
and now I have access to the qt broswer.

Visualization (optional)
β”œβ˜‘ pyvista           0.42.3 (OpenGL unavailable)
β”œβ˜‘ pyvistaqt         0.11.0
β”œβ˜‘ vtk               9.2.6
QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700
β”œβ˜‘ qtpy              2.4.1 (PyQt5=5.15.8)
β”œβ˜‘ ipympl            0.9.3
β”œβ˜‘ pyqtgraph         0.13.3
β”œβ˜‘ mne-qt-browser    0.6.1
β”œβ˜‘ ipywidgets        8.1.1
β”œβ˜‘ trame_client      2.12.6
β”œβ˜‘ trame_server      2.12.1
β”œβ˜‘ trame_vtk         2.6.2
β””β˜‘ trame_vuetify     2.3.1

Now I’m wondering if I should be using a PyQt6 library. Is there a preferred one? It looks like PySide is also an option, but that seems like another rabbit hole to research…

Are these missing libraries something that the installer should be checking for as dependencies?

The browser will work with either qt bindings: pyqt5, pyqt6, PySide2, Pyside6.

Mathieu