MNE installation / matplotlib issue

  • MNE version:1.9.0
  • operating system: e.g. macOS Sequoia 15.2, M1 Pro (silicon chip)

Hi everyone,

I previously had some widespread problems, being traced back to matplotlib’s incompatibility with newer macOS versions. Apparently, OpenGL has been deprecated in newer versions, and as far as I could understand, this is creating an issue with matplotlib.

Since plotting is at the heart of what I do, I tried re-installing everything as suggested:

Now I have several new problems:

  1. When I installed mne in a new conda env (I wanted to avoid using the standalone installer, because it made installing new packages complicated for me in the past, and somehow hijacked my base environment, such that my base env was MNE and no matter what I did, I could not change that). Now when installed spyder in my new conda env with mne, spyder opened but console was unavailable due to this error:
/Users/denizyilmaz/.matplotlib is not a writable directory
Matplotlib created a temporary cache directory at /var/folders/hw/ptzt2r6n08q4_jhx1fpg9fpm0000gn/T/matplotlib𔂲zlzn0bx because there was an issue with the default path (/Users/denizyilmaz/.matplotlib); it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.

Here, creating a writable dir did not solve the issue.

Also, there was an error message on the terminal, when I tried to open spyder from the terminal, with the mne env activated:

(mne_env) denizyilmaz@Denizs-MacBook-Pro ~ % spyder
The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.
Chromium on macOS will fall back to software rendering in this case.
Hardware acceleration and features such as WebGL will not be available.
Populating font family aliases took 202 ms. Replace uses of missing font family "Manrope" with one that exists to avoid this cost. 
2025-01-17 13:10:48.026 python[13578:577610] +[IMKClient subclass]: chose IMKClient_Modern
2025-01-17 13:10:48.026 python[13578:577610] +[IMKInputSession subclass]: chose IMKInputSession_Modern
  1. I created a test env without mne installed, spyder opened without a problem. So I narrowed it down to these packages:
(mne_env) denizyilmaz@Denizs-MacBook-Pro ~ % conda list | grep -E "matplotlib|pyqt|qt"

matplotlib                3.10.0          py310hca03da5_0  
matplotlib-base           3.10.0          py310h7ef442a_0  
matplotlib-inline         0.1.7              pyhd8ed1ab_1    conda-forge
mne                       1.9.0           pyqt_h8d421b4_201    conda-forge
mne-qt-browser            0.6.3              pyh0555025_1    conda-forge
pyqt                      5.15.10         py310h313beb8_1  
pyqt5-sip                 12.13.0         py310h80987f9_1  
pyqtgraph                 0.13.7             pyhd8ed1ab_1    conda-forge
pyqtwebengine             5.15.10         py310h313beb8_1  
pyvistaqt                 0.11.1             pyhdecd6ff_1    conda-forge
qt-main                   5.15.15              h7d33341_0    conda-forge
qt-webengine              5.15.9               h2903aaf_7  
qt6-main                  6.7.3                h3c9d44f_0    conda-forge
qtawesome                 1.3.1           py310hca03da5_0  
qtconsole                 5.6.0           py310hca03da5_0  
qtpy                      2.4.2              pyhd8ed1ab_1    conda-forge
sphinxcontrib-qthelp      1.0.3              pyhd3eb1b0_0  
superqt                   0.6.7           py310h33ce5c2_0  
vtk                       9.3.1           qt_py310h07c347a_201    conda-forge
vtk-base                  9.3.1           qt_py310h313fd62_201    conda-forge
vtk-io-ffmpeg             9.3.1           qt_py310h64321a6_201    conda-forge
(mne_env) denizyilmaz@Denizs-MacBook-Pro ~ % conda activate test_env
(test_env) denizyilmaz@Denizs-MacBook-Pro ~ %  conda list | grep -E "matplotlib|pyqt|qt"
matplotlib-inline         0.1.6           py310hca03da5_0  
pyqt                      5.15.10         py310h313beb8_1  
pyqt5-sip                 12.13.0         py310h80987f9_1  
pyqtwebengine             5.15.10         py310h313beb8_1  
qt-main                   5.15.2              h0917680_11  
qt-webengine              5.15.9               h2903aaf_7  
qtawesome                 1.3.1           py310hca03da5_0  
qtconsole                 5.6.0           py310hca03da5_0  
qtpy                      2.4.1           py310hca03da5_0  
sphinxcontrib-qthelp      1.0.3              pyhd3eb1b0_0  
superqt                   0.6.7           py310h33ce5c2_0  
(test_env) denizyilmaz@Denizs-MacBook-Pro ~ % 

But then trying to downgrade them did not work.

  1. I tried to install MNE with the standalone installer once more, to check whether the problems are due to the conda installation. I did not delete the previous environments or my initial installations (which may have been a mistake?) and now MNE is installed but when I try to open Spyder (MNE) it opens in the dock and disappears immediately without the GUI appearing. Also, my initial conda env is not opening spyder.
(mne) denizyilmaz@Denizs-MacBook-Pro ~ % spyder
zsh: command not found: spyder

Did the installer overwrite everything I previously did somehow?

  1. I also tried VScode, to see whether the issue is Spyder-specific. I got the same error in the Interactive:
/Users/denizyilmaz/.matplotlib is not a writable directory
Matplotlib created a temporary cache directory at /var/folders/hw/ptzt2r6n08q4_jhx1fpg9fpm0000gn/T/matplotlib-opix7sdm because there was an issue with the default path (/Users/denizyilmaz/.matplotlib); it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
Matplotlib is building the font cache; this may take a moment.

However, it allows me to run code and plot raw data, for instance.
I do like Spyder very much, though, mainly because of the Variable pane, and would like to be able to use MNE on Spyder.

I would appreciate any sort of help very much!
Thanks in advance.

Cheers,
Deniz

Can you try removing that directory (or make it user writeable)?

Just for the record, Matplotlib works perfectly fine on the latest macOS (I’m neither using conda nor spyder though).

@deniz_yilmaz Can you try to create a fresh MNE conda environment and not installing Spyder into it, but instead using the Spyder standalone version (can be downloaded from the Spyder website)?

Regarding the trouble with the installers, I will try to take a look at this later today. Please tag me here if you don’t hear back from me by the end of the week! cc @larsoner

Best wishes
Richard

I tried these:

mkdir -p ~/.matplotlib
export MPLCONFIGDIR=~/.matplotlib
sudo chown $USER ~/.matplotlib

This did not work, unfortunately. Would you advise a different way?

RESOLVED!

I reinstalled everything now: fresh mne conda env & spyder 6 standalone.

Got the same matplotlib error, not allowing me to interact with the console.

Then, I removed the matplotlib dir (as @cbrnr suggested) instead of changing permissions:

conda install spyder-kernels=3.0

I got an error saying spyder was not installed (I assumed it would be installed because it was a system-wide standalone installation?).

So then, instead of installing spyder in mne env, I ran:

conda activate mne
conda install spyder-kernels=3.0

And then, after two restarts of Spyder, finally, I had an error-free console and was able to set my interpreter as “/Users/denizyilmaz/miniconda3/envs/mne/bin/python” (which earlier did not work).

Yay, thank you both very much! @richard @cbrnr

Best,
Deniz

Nice! I’m glad that it worked out!

One last, minor but related issue pertaining to the major topic remains.

I was able to perform a pilot analysis, and plotting works normally (yay! :)).

However, when I run this:

mne.sys_info()

I get this and python quits and restarts:

Fatal Python error: Segmentation fault


Main thread:
Current thread 0x0000000202c7c240 (most recent call first):
  File "/Users/denizyilmaz/miniconda3/envs/mne/lib/python3.12/site-packages/mne/viz/backends/_utils.py", line 190 in _init_mne_qtapp
  File "/Users/denizyilmaz/miniconda3/envs/mne/lib/python3.12/site-packages/mne/utils/check.py", line 1015 in _check_qt_version
  File "/Users/denizyilmaz/miniconda3/envs/mne/lib/python3.12/site-packages/mne/utils/config.py", line 857 in sys_info
  File "/var/folders/hw/ptzt2r6n08q4_jhx1fpg9fpm0000gn/T/ipykernel_16102/3389385014.py", line 1 in <module>

Issues with visualization backend were the initial trigger, prompting me to reinstall everything. And also in the new reinstallment, it somehow keeps popping up (matplotlib error, openGL error, etc.).
Do you think something is falsely configured in my overall system wich interferes with Qt, or is there something within MNE that you are aware of that may cause issues with the backend? This seems to only be an issue in my mne environment.

Since I just reinstalled everything, I am hesitant to reinstall specific packages or up- or down-grade them and cause further dependency issues.

Thanks once more for the clarification and all your support!

Best,
Deniz

It’s hard to say, but since Spyder is also Qt-based, I would not be surprised that this causes that issue. I know you really like Spyder, but in my experience you will experience way fewer issues when switching to either VS Code or PyCharm.

Thank you, I will experiment with VSCode and see how steep my learning curve is :grin:

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