New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jupyter yields: 'NoneType' object has no attribute '_get_renderer' #11799
Comments
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴 |
did you put
%matplotlib inline
in your notebook?
… Message ID: ***@***.***>
|
Yes, the issue persists whether it is there or not. I've tried %matplotlib notebook and it yields |
Try installing ipympl |
Issue persists with ipympl. |
OK looking a bit closer, I'm confused by your If it were me, I'd create a fresh env that has everything I need (python, ipython, jupyter, matplotlib, mne, ...) and make sure when starting the notebook that it's the version of jupyter in that environment (command line would be import jupyter
print(jupyter.__file__) to see the path to the jupyter installation being used. (sometimes You can do similar |
Indeed, it seems that I forgot to terminate the Jupyter notebook when I created a fresh environment for testing.
print(jupyter.__file__) Correctly shows the path to my test env. |
ok... I notice I don't personally use PyCharm but IIRC they do some things to wrap matplotlib (capture plots and stick them in a separate pane? or something...) maybe @hoechenberger or @cbrnr know? |
I've tried both in Pycharm and in browser. I've also tried starting Jupyter from Pycharm and starting Jupyter from terminal. Same error every time. |
I don't use PyCharm anymore, but this doesn't seem to be the issue. I don't use Jupyter notebooks either, but I could replicate your issue. I could fix it with:
at the top of the notebook. |
Hello, @cbrnr and I just hosted an MNE workshop where we used Jupyter Notebook and this problem did not occur. Users were asked to install MNE-Python through our installers. Can you try with one of our installers? Also:
what does that mean, what did you do? |
argh. OK I'm back at my desk now and I can reproduce it locally (on linux, in terminal/browser). My next thought was "system python used as kernel" so I installed I won't have more time today to debug unfortunately, but will try tomorrow unless someone beats me to it. reproducer: mamba create -n test mne jupyter nb_conda_kernels
jupyter notebook then copy-paste this into the notebook: %matplotlib inline
import mne
raw = mne.io.read_raw_fif("demo-data.fif", preload=True)
events, event_dict = mne.events_from_annotations(raw)
epochs = mne.Epochs(
raw,
events,
event_id=event_dict,
tmin=-.5,
tmax=1,
)
epochs[["Test Trial"]].average().plot() |
Try |
If I force |
@drammock Yes it works with matplotlib 3.7.1 ! Jupyter probably updated when I installed pyqt, 3.7.2 was released 2 weeks ago. It seems that mne, matplotlib and jupyter don't mesh well with this latest update. Thanks for helping me troubleshoot the issue, not sure if the issue lies with matplotlib or mne then. Either way, downgrading matplotlib works for now, I'm closing the issue. |
just a note that this Matplotlib bug is already fixed upstream and should land in version 3.7.3 issue: matplotlib/matplotlib#26287 |
Description of the problem
When trying to visualize mne data in a jupyter notebook, I get the following error:
'NoneType' object has no attribute '_get_renderer'
Steps to reproduce
So this is a strange one, everything was working perfectly and then I tried to get pyqt to work and now I can't have the normal matplotlib inline experience in jupyter notebooks.
The code runs fine and the plots show normally in a python script, but crashes in a jupyter notebook.
I was unable to reproduce it on the sample datasets, I'm providing a snippet of my dataset.
In a notebook, load the data and try to visualize evoked data.
Link to data
https://drive.google.com/file/d/1hAVBZaxg1ZVorf5djqbDB8mdhAtdkf5v/view?usp=sharing
Expected results
I should see the plot
Actual results
I get the following stack trace:
Additional information
I've tried uninstalling and reinstalling all packages, adding and removing all visualization packages as well. I can get the plots to show on sample data in a notebook and even on my data but not in notebooks.
I've been able to reproduce it in a fresh project and in a fresh env, with only mne installed.
mne.sys_info()
poetry show
Thanks in advance !
The text was updated successfully, but these errors were encountered: