Installation Issues - Conflict between qt5 and qt6

Hello! I have been having issues with creating plots with mne, for example stc.plot(). I have installed mne multiple times (with conda and using the installer). I even removed conda and reinstalled it again but there is an error at the time of installation that persists. The installation procedure works fine but when I try to validate it using sys.info(), I get this error:

  • MNE version: 1.8.0
  • operating system: e.g. macOS 14

(improved_mne) % python -c "import mne; mne.sys_info()"

Platform macOS-14.4-arm64-arm-64bit
Python 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 15:57:01) [Clang 17.0.6 ]
Executable /opt/anaconda3/envs/improved_mne/bin/python
CPU arm (12 cores)
Memory 18.0 GB

Core
β”œβ˜‘ mne 1.8.0 (latest release)
β”œβ˜‘ numpy 1.26.4 (OpenBLAS 0.3.27 with 12 threads)
β”œβ˜‘ scipy 1.14.1
Matplotlib is building the font cache; this may take a moment.
β””β˜‘ matplotlib 3.9.2 (backend=macosx)

Numerical (optional)
β”œβ˜‘ sklearn 1.5.2
β”œβ˜‘ numba 0.60.0
β”œβ˜‘ nibabel 5.3.0
β”œβ˜‘ nilearn 0.10.4
β”œβ˜‘ dipy 1.9.0
β”œβ˜‘ openmeeg 2.5.12
β”œβ˜‘ pandas 2.2.2
β”œβ˜‘ h5io 0.2.4
β”œβ˜‘ h5py 3.11.0
β””β˜ unavailable cupy

Visualization (optional)
β”œβ˜‘ pyvista 0.44.1 (OpenGL 4.1 Metal - 88 via Apple M3 Pro)
β”œβ˜‘ pyvistaqt 0.11.1
objc[3144]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /opt/anaconda3/envs/improved_mne/lib/libQt5Core.5.15.8.dylib (0x3183b92e0) and /opt/anaconda3/envs/improved_mne/lib/libQt6Core.6.7.3.dylib (0x320be5558). One of the two will be used. Which one is undefined.
objc[3144]: Class KeyValueObserver is implemented in both /opt/anaconda3/envs/improved_mne/lib/libQt5Core.5.15.8.dylib (0x3183b9308) and /opt/anaconda3/envs/improved_mne/lib/libQt6Core.6.7.3.dylib (0x320be5580). One of the two will be used. Which one is undefined.
objc[3144]: Class RunLoopModeTracker is implemented in both /opt/anaconda3/envs/improved_mne/lib/libQt5Core.5.15.8.dylib (0x3183b9358) and /opt/anaconda3/envs/improved_mne/lib/libQt6Core.6.7.3.dylib (0x320be55d0). One of the two will be used. Which one is undefined.
β”œβ˜‘ vtk 9.3.1
zsh: segmentation fault python -c β€œimport mne; mne.sys_info()”


After this I get an error window telling me that python has crashed. I am attaching a couple of lines of the error message:


Translated Report (Full Report Below)

Process: python3.12 [3332]
Path: /opt/anaconda3/*/python
Identifier: python3.12
Version: ???
Code Type: ARM-64 (Native)
Parent Process: zsh [2590]
Responsible: pycharm [1532]
User ID: 501

Date/Time: 2024-10-15 15:17:55.3061 +0200
OS Version: macOS 14.4 (23E214)
Report Version: 12
Anonymous UUID: 1ECFF9FA-B932-B25E-A5B9-B90BE62633EA

Time Awake Since Boot: 3300 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000

Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [3332]

VM Region Info: 0 is not in any region. Bytes before following region: 4345118720
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
β€”>
__TEXT 102fd4000-103380000 [ 3760K] r-x/r-x SM=COW /opt/anaconda3/*/python3.12

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libQt6Gui.6.7.3.dylib 0x301ac4998 +[NSImage(QtExtras) imageFromQIcon:withSize:] + 760
1 libqcocoa.dylib 0x3084ee2dc 0x3084e4000 + 41692
2 python3.12 0x10309a688 cfunction_call + 308
3 python3.12 0x10303e6d8 _PyObject_MakeTpCall + 316
4 python3.12 0x10316d7c0 _PyEval_EvalFrameDefault + 57428
5 python3.12 0x10315e83c PyEval_EvalCode + 300
6 python3.12 0x1031d81a8 run_mod + 228
7 python3.12 0x1031dbd0c PyRun_SimpleStringFlags + 336
8 python3.12 0x103203a44 Py_RunMain + 2420
9 python3.12 0x103204984 pymain_main + 628
10 python3.12 0x102fd77c0 main + 56
11 dyld 0x181ce20e0 start + 2360

Thread 1:
0 libsystem_pthread.dylib 0x182065d20 start_wqthread + 0

Thread 2:
0 libsystem_pthread.dylib 0x182065d20 start_wqthread + 0

Thread 3:
0 libsystem_kernel.dylib 0x18202d9ec __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x18206b55c _pthread_cond_wait + 1228
2 interpreter.cpython-312-darwin.so 0x14a98205c th_worker(void*) + 152
3 libsystem_pthread.dylib 0x18206af94 _pthread_start + 136
4 libsystem_pthread.dylib 0x182065d34 thread_start + 8

Thread 4:
0 libsystem_kernel.dylib 0x18202d9ec __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x18206b55c _pthread_cond_wait + 1228
2 interpreter.cpython-312-darwin.so 0x14a98205c th_worker(void*) + 152
3 libsystem_pthread.dylib 0x18206af94 _pthread_start + 136
4 libsystem_pthread.dylib 0x182065d34 thread_start + 8

Thread 5:
0 libsystem_kernel.dylib 0x18202d9ec __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x18206b55c _pthread_cond_wait + 1228
2 interpreter.cpython-312-darwin.so 0x14a98205c th_worker(void*) + 152
3 libsystem_pthread.dylib 0x18206af94 _pthread_start + 136
4 libsystem_pthread.dylib 0x182065d34 thread_start + 8


I understand that there may be a conflict between qt5 and qt6, but I am not sure how to resolve this. Should I remove one or the other package?
Thanks for your help!

pinging @larsoner as the Qt guru - Do you have any insight into the problem here? It looks like @r_ally has both Qt5core and Qt6core installed in their conda environment. Given the warnings in the stack trace, I assume that this is a prime candidate for the failure.

Indeed this is a problem with having both frameworks installed :frowning: In theory nowadays you should be able to (with conda-forge as your selected channel at least) install things like matplotlib, mayavi, etc. with Qt6 support via PySide6, and not need any pyqt. If you try conda remove pyqt qt-main it should tell you what it’s going to try to remove alongside PyQt5 and qt5.

1 Like

Thank you for your quick replies!
I ran the command conda remove pyqt qt-main and got this message shown:

Channels:
 - defaults
 - conda-forge
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /opt/anaconda3/envs/improved_mne

  removed specs:
    - pyqt
    - qt-main


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    mne-1.8.0                  |pyside6_h60f6096_100         623 KB  conda-forge
    pyside6-6.7.3              |  py312h943ac22_1        11.4 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        12.0 MB

The following NEW packages will be INSTALLED:

  pyside6            conda-forge/osx-arm64::pyside6-6.7.3-py312h943ac22_1 

The following packages will be REMOVED:

  glib-2.82.1-he7aae3a_1
  glib-tools-2.82.1-he5bafa0_1
  gst-plugins-base-1.24.7-hb49d354_0
  gstreamer-1.24.7-hc3f5269_0
  libclang-cpp15-15.0.7-default_he012953_5
  libintl-devel-0.22.5-h8414b35_3
  libllvm15-15.0.7-h2621b3d_4
  nspr-4.35-hb7217d7_0
  nss-3.105-hd1ce637_0
  ply-3.11-pyhd8ed1ab_2
  pyqt-5.15.9-py312h550cae4_5
  pyqt5-sip-12.12.2-py312h9f69965_5
  qt-main-5.15.8-h1c95b31_26
  sip-6.8.6-py312hde4cb15_1
  toml-0.10.2-pyhd8ed1ab_0

The following packages will be DOWNGRADED:

  mne                               1.8.0-pyqt_h8d421b4_200 --> 1.8.0-pyside6_h60f6096_100 


Proceed ([y]/n)?

Does it make sense to remove pyqt and qt-main then?
Thanks again!

I would say this looks reasonable, yes!

1 Like

Thank you all for the help. I did remove PyQt and qt-main as suggested and indeed I got rid of the issue when I printed sys_info(). I get the following output printed.

Downloading and Extracting Packages:
                                                                                                                                                                                                
Preparing transaction: done                                                                                                                                                                     
Verifying transaction: done
Executing transaction: done
(improved_mne) % python -c "import mne; mne.sys_info()"
Platform             macOS-14.4-arm64-arm-64bit
Python               3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 15:57:01) [Clang 17.0.6 ]
Executable           /opt/anaconda3/envs/improved_mne/bin/python
CPU                  arm (12 cores)
Memory               18.0 GB

Core
β”œβ˜‘ mne               1.8.0 (latest release)
β”œβ˜‘ numpy             1.26.4 (OpenBLAS 0.3.27 with 12 threads)
β”œβ˜‘ scipy             1.14.1
β””β˜‘ matplotlib        3.9.2 (backend=macosx)

Numerical (optional)
β”œβ˜‘ sklearn           1.5.2
β”œβ˜‘ numba             0.60.0
β”œβ˜‘ nibabel           5.3.0
β”œβ˜‘ nilearn           0.10.4
β”œβ˜‘ dipy              1.9.0
β”œβ˜‘ openmeeg          2.5.12
β”œβ˜‘ pandas            2.2.2
β”œβ˜‘ h5io              0.2.4
β”œβ˜‘ h5py              3.11.0
β””β˜ unavailable       cupy

Visualization (optional)
β”œβ˜‘ pyvista           0.44.1 (OpenGL 4.1 Metal - 88 via Apple M3 Pro)
β”œβ˜‘ pyvistaqt         0.11.1
β”œβ˜‘ vtk               9.3.1
β”œβ˜‘ qtpy              2.4.1 (PySide6=6.7.3)
β”œβ˜‘ pyqtgraph         0.13.7
β”œβ˜‘ mne-qt-browser    0.6.3
β”œβ˜‘ ipywidgets        8.1.5
β”œβ˜‘ trame_client      3.3.2
β”œβ˜‘ trame_server      3.2.3
β”œβ˜‘ trame_vtk         2.8.10
β”œβ˜‘ trame_vuetify     2.7.1
β””β˜ unavailable       ipympl

Ecosystem (optional)
β”œβ˜‘ eeglabio          0.0.2-4
β”œβ˜‘ edfio             0.4.4
β”œβ˜‘ mffpy             0.10.0
β”œβ˜‘ pybv              0.7.5
β””β˜ unavailable       mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo

However when I try to use stc.plot() as in the following code (having changed the matplotlib backend from MacOSX to TkAgg):

brain = GA_stc_diff.plot(subjects_dir=mri_dir, subject='fsaverage', surface='white', hemi='both', time_viewer=True, src=fs_src, show_traces=False)
brain.add_annotation('aparc', borders=1, alpha=0.9)

I get the following issue before a plot gets printed. However, this plot doesn’t allow me to interact with it and a loading cursor keeps showing until I force quit python.
ERROR:root:Invalid Qt API 'pyside6', valid values are: 'pyside', 'pyqt', 'pyqt5', 'pyqt6'

is there a way about it?
Many thanks!

Hi @r_ally can you share the full stack trace (that resulted in the ERROR:root:Invalid Qt API ... )?

Hi @scott-huberty!
Currently I am debugging using PyCharm. When I let the debugger plot, I do not get this error anymore. I get a plot but I cannot interact with it. I see this output before the plot opens up:

Using pyvistaqt 3d backend.
Using control points [1.25711561 1.27690406 1.34160075]

However when I run the plotting commands e.g., this:

brain = GA_stc_diff.plot(subjects_dir=mri_dir, subject='fsaverage', surface='white', hemi='both', time_viewer=True, src=fs_src, show_traces=False)
brain.add_annotation('aparc', borders=1, alpha=0.9)

and execute them in the python console, I get the following error:

PyDev console: using IPython 8.28.0
Using control points [1.22882155 1.24525744 1.3952161 ]
ERROR:root:Invalid Qt API 'pyside6', valid values are: 'pyside', 'pyqt', 'pyqt5', 'pyqt6'

A little update.
I am able to plot all my figures and interact with them. However, I can only do this when I run IPython in my Terminal using something like this to initialise the IPython console:
ipython --gui=qt

However, when debugging using the PyCharm debugger or executing commands in the Python console, I am still facing the same issue - owing to most likely the way I have configured things. But my main aim was to get the plots, which I have achieved, so that would be a battle for another day.
Thanks all for the help!

2 Likes

Hi @r_ally ,

glad you got it slightly working!

If you would like help trouble shooting further, feel free to stop by the MNE-Python Office hours this Friday: MNE Office Hours on Discord

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.