# Warnings and error messages when using mne-qt-browser

**URL:** <https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915>\
**Category:** Support & Discussions\
**Tags:** visualization, qt-browser\
**Created:** [November 5, 2021, 2:54pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915 "2021-11-05T14:54:29Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulF](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PaulF](https://mne.discourse.group/u/PaulF)\
**Post date:** [November 5, 2021, 2:54pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/1 "2021-11-05T14:54:29Z")

</div>

- MNE-Python version: 0.24
- operating system: Mac OS 11.3.1

I just updated to .24 and love the new data browser. I have a question about a warning message I’m receiving along with an error message when using the browser with tkinter.

Following the simple example at [GitHub - mne-tools/mne-qt-browser: A new backend for the 2D data browser in MNE-Python](https://github.com/mne-tools/mne-qt-browser), I started with

```python
import mne
mne.viz.set_browser_backend("pyqtgraph")
raw = mne.io.read_raw_edf('myfile.edf',preload=True)
raw.plot(block=True,duration=40,start=10)

```

The data browser appears and works fine, but I also receive a warning message:

> ```python
> RuntimeWarning: PyOpenGL was not found and OpenGL can't be used!
> Consider installing pyopengl with "pip install pyopengl".
> 
> ```

I then installed pyopengl and ran the code again, only to obtain an extremely long error message ending with the following:

> `ImportError: ('Unable to load OpenGL library', 'dlopen(OpenGL, 10): image not found', 'OpenGL', None)`

I then uninstalled pyopengl just so I could at least get things to work.

**Question 1:** I don’t really understand the roles of OpenGL and PyOpenGL and whether I should be concerned about this warning and, if I should be, how I can go about resolving it.

My second question focuses on embedding raw plots on figure tkinter figure canvases. With the previous raw.plot(), I used the following syntax to do this:

```python
import mne
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.backends.backend_tkagg as tkagg
from tkinter import Tk, Frame,TOP,BOTTOM

root = Tk()
root.wm_title("Main Window")
root.geometry('1500x1000')

raw = mne.io.read_raw_edf('myfile.edf',preload=True)

fig=raw.plot(block=True,duration=40,start=10)
canvas_frame=Frame(root,height = 1500,width = 1000)
canvas_frame.pack(side=TOP,expand=True)
canvas = FigureCanvasTkAgg(fig, master=canvas_frame)
canvas.draw()
canvas.get_tk_widget().pack(side=TOP,fill=BOTH,expand=1)

root.mainloop()

```

This has worked very well for me. However, when I insert `mne.viz.set_browser_backend("pyqtgraph")` so as to place the updated browser on the canvas, I receive the same warning as above, along with a lengthy error message ending with

> AttributeError: ‘PyQtGraphBrowser’ object has no attribute ‘set\_canvas’

**Question 2** : Is this error related to the above warning and/or is there some other explanation?

I realize mne-qt-browser is a new feature, so please let me know if I should post these questions on its associated github page instead.

---

<div class="post-metadata">

**Author:** ![PaulF](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PaulF](https://mne.discourse.group/u/PaulF)\
**Post date:** [November 5, 2021, 5:46pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/2 "2021-11-05T17:46:59Z")

</div>

**Update:** I’ve been able to resolve the first issue, which appears to be specific to my Mac Big Sur OS. A description of the problem and a simple solution are outlined at [Unable to import opengl.gl in python on macos - Stack Overflow](https://stackoverflow.com/questions/63475461/unable-to-import-opengl-gl-in-python-on-macos)

With regard to placing the mne-qt-browser plot on a canvas, the error message,

`AttributeError: ‘PyQtGraphBrowser’ object has no attribute ‘set_canvas’`

still results, but only when I close the figure.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [November 5, 2021, 8:26pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/3 "2021-11-05T20:26:37Z")

</div>

I don’t have the necessary experience with Tk or Qt to tell you the answer, but a quick google search for `embed qt in tk` turns up a couple promising-looking pages:

- [How to create a QWidget with a Tk window as parent? | Qt Forum](https://forum.qt.io/topic/29430/how-to-create-a-qwidget-with-a-tk-window-as-parent)
- [Tq - Integrate Qt with Tk GUIs • froglogic](https://www.froglogic.com/tq/)

---

<div class="post-metadata">

**Author:** ![marsipu](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/marsipu/32/196_2.png) [@marsipu](https://mne.discourse.group/u/marsipu)\
**Post date:** [November 7, 2021, 8:21pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/4 "2021-11-07T20:21:17Z")

</div>

Hello Paul,

thank you for your hint to the solution of the OpenGl-Problem on MacOs. It is good to know that there can be issues with OpenGL and Big Sur.

Martin

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [November 8, 2021, 7:36am UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/5 "2021-11-08T07:36:33Z")

</div>

@PaulF Which version of Python are you using? Could you please share the output of

```python
import mne
mne.sys_info()

```

Thanks!

---

<div class="post-metadata">

**Author:** ![PaulF](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PaulF](https://mne.discourse.group/u/PaulF)\
**Post date:** [November 8, 2021, 1:02pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/6 "2021-11-08T13:02:22Z")

</div>

> [@richard](#):
>

Yes–here it is:

Platform: macOS-10.16-x86\_64-i386-64bit  
Python: 3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) [Clang 6.0 (clang-600.0.57)]  
Executable: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9  
CPU: i386: 8 cores  
Memory: 32.0 GB

mne: 0.24.0  
numpy: 1.21.3 {blas=openblas, lapack=openblas}  
scipy: 1.7.1  
matplotlib: 3.4.2 {backend=MacOSX}

sklearn: 0.24.1  
numba: Not found  
nibabel: Not found  
nilearn: Not found  
dipy: Not found  
cupy: Not found  
pandas: 1.2.4  
mayavi: Not found  
pyvista: Not found  
pyvistaqt: Not found  
ipyvtklink: Not found  
vtk: Not found  
PyQt5: 5.15.6  
ipympl: Not found  
mne\_qt\_browser: 0.1.6

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [November 8, 2021, 1:27pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/7 "2021-11-08T13:27:29Z")

</div>

There is a problem with macOS Big sure that moved some standard library elsewhere, and the paths are invalid when using ‘old’ python version. For instance, I run python 3.8.10 and I ran into this problem with multiple third-parties libraries already.

Don’t quote me on that, but I think it was solved in Python 3.9.3. So if you upgrade to a more recent 3.9 version, you should not need to patch this with `'/System/Library/Frameworks/OpenGL.framework/OpenGL'`.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [November 8, 2021, 1:46pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/8 "2021-11-08T13:46:33Z")

</div>

> [@mscheltienne](#):
>
> Don’t quote me on that, but I think it was solved in Python 3.9.3

Yep, this fix def. made it into Python 3.9 and was also backported to 3.8.

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [November 8, 2021, 2:08pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/9 "2021-11-08T14:08:09Z")

</div>

Indeed! Fix in 3.9.7 (I knew I shouldn’t be quoted on 3.9.3 😛) and backported to 3.8.12.

---

<div class="post-metadata">

**Author:** ![PaulF](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PaulF](https://mne.discourse.group/u/PaulF)\
**Post date:** [November 8, 2021, 2:40pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/10 "2021-11-08T14:40:13Z")

</div>

What about upgrading to 3.10? I just tried this but received the following error when trying to import mne:

> import mne  
> Traceback (most recent call last):  
> File “\<pyshell#8\>”, line 1, in   
> import mne  
> File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mne/ **init**.py”, line 22, in   
> from .utils import (set\_log\_level, set\_log\_file, verbose, set\_config,  
> File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mne/utils/ **init**.py”, line 9, in   
> from .check import (check\_fname, check\_version, check\_random\_state,  
> File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mne/utils/check.py”, line 21, in   
> from …fixes import \_median\_complex  
> File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mne/fixes.py”, line 360, in   
> ‘preserves\_dtype’: [np.float64],  
> AttributeError: module ‘numpy’ has no attribute ‘float64’

My version of numpy is up to date. (1.21.4).

Perhaps I should go back, uninstall 3.10, and install 3.9.7?

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [November 8, 2021, 3:12pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/11 "2021-11-08T15:12:49Z")

</div>

Python 3.10 is a bit too recent to my liking (minor version 0!), and you will probably encounter a lot of bugs like this one. I would suggest using the latest 3.9 version instead, 3.9.8.

---

<div class="post-metadata">

**Author:** ![marsipu](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/marsipu/32/196_2.png) [@marsipu](https://mne.discourse.group/u/marsipu)\
**Post date:** [November 12, 2021, 2:42pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/12 "2021-11-12T14:42:48Z")

</div>

@PaulF  
Concerning your original questions:

#### Question 1

We found that OpenGL only enhances performance for some hardware-configurations. Since it also turned out to cause additional problems as in your case, the new default for `use_opengl` is now `False`. To avoid the warning, you can now manually set `use_opengl` to `False`, this won’t be necessary anymore with version 0.24.1 of MNE-Python.

#### Question 2

I tried to find a solution for your problem, but unfortunately it seems that [PyQt and tkinter aren’t compatible](https://stackoverflow.com/questions/8497142/python-adding-a-tkinter-graph-to-a-pyqt-widget).  
What `raw.plot()` returns is an instance of QWidget (or more specific a subclass, QMainWindow) which can be integrated into PyQt-Applications.  
The `FigureCanvasTkAgg`-Class you use wraps instances of `matplotlib.figure.Figure` to be used with tkinter.

I would be glad to help you if you got questions about integrating PyQtBrowser into a PyQt-Application. Otherwise you need to continue using `matplotlib` for your tkinter-application.

---

<div class="post-metadata">

**Author:** ![PaulF](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PaulF](https://mne.discourse.group/u/PaulF)\
**Post date:** [November 15, 2021, 5:28pm UTC](https://mne.discourse.group/t/warnings-and-error-messages-when-using-mne-qt-browser/3915/13 "2021-11-15T17:28:19Z")

</div>

Thanks Martin for looking into this. I very much appreciate it. Given all the matplotlib tools I’ve integrated into my tkinter app at this point, I think I’ll just stick with what I’m doing. In hindsight perhaps I should have utilized PyQt since the start so I could integrate your beautiful data browser into what I’m doing.

Thanks again.

Paul
