fipy
fipy copied to clipboard
Viewer problem 'non-GUI backend' with Spyder's IPython console
Hello,
I recently updated to Spyder 5 on MacOS and have been using FiPy in combination with Spyder for a long time. After this new update the viewers don't work anymore in the inlined IPython console.
For reproducibility I created a new conda environment with fipy, following the installation instructions
conda create --name test --channel conda-forge fipy
then installed spyder in the newest version and updated the environment's packages.
If I run the diffusion/mesh1D.py example as a script (i.e. using the python setup.py copy_script --From x.py --To y.py
command to create a python script), I get the following error:
/Users/***/anaconda3/envs/test/lib/python3.9/site-packages/fipy/viewers/matplotlibViewer/matplotlibViewer.py:195: UserWarning: Matplotlib is currently using module://matplotlib_inline.backend_inline, which is a non-GUI backend, so cannot show the figure. self.fig.show()
A workaround is to use the Qt5 backend via matplotlib.use('Qt5Agg')
and switch in Spyder to the Qt5 output of the IPython console, which yields an external viewer window. However, I prefer the inlined version.
Is it related to the FiPy implementation of the custom viewers and is it possible to fix this such that one gets the expected behavior back (i.e. successive inline plots after redrawing the plot, since updating does not work in IPython consoles, correct?).
Thank you.
Thanks for the report. We'll look into it.
This is a warning and not an error.
Spyder/matplotlib appears to not support dynamic displays in inline mode. Jupyter/matplotlib doesn't either, but the workaround we use there, involving IPython.display.clear_output
and IPython.display.display
does not work cleanly in Spyder (you get another inline image every time you call .plot()
). It looks like that's what you want. I'll have to figure out how to recognize when we're running under Spyder.
Hmmm... not actually what you want. You get another image for every call to .plot()
, but all of the images update, so you get lots of copies of the latest plot, instead of a sequence of snapshots.
To see this, add to _isnotebook()
:
elif shell == 'SpyderShell':
return True # Spyder IDE