Open Vital-Fernandez opened 3 months ago
Thanks for the report, can you please provide a minimal reproducible example?
I don't have any experience with the widget
backend, I assume it worked before your re-installation?
I have created #794 to test this, and it seems to work. What is different in your case?
Hi @mgeier - I'm facing the same issue. I have attached a zip file with
an example pre-processed notebook, the conf.py
and index.rst
to reproduce this, and the html produced directly by nbconvert.
Notes:
nbconvert
correctly renders the page with the figure (using jupyter nbconvert --to html ipympl-lab-test.ipynb
)Error displaying widget: model not found
) - some issue in jupyter-lab not using the embedded png as an alternate representation of the graph. Since nbconvert
works I expect it should also work with nbsphinx
The minimal test environment was created using mambaforge with just mamba create -n ipympl-lab python=3.12 ipympl matplotlib jupyterlab sphinx nbsphinx
.
A followup: after a few more tests, there is an option "save widget state automatically" in jupyter-lab:
Once this is activated this seems to change something in the saved processed notebook, and the rendering is then correct using both nbsphinx
and nbconvert
, and also when re-opening the notebook in jupyter-lab.
Maybe @Vital-Fernandez can confirm if this also solves the issue for him.
Yes, the widget state needs to be available for the widget to be shown in the HTML page.
Do you want to add this to the documentation, maybe at https://nbsphinx.readthedocs.io/en/0.9.4/code-cells.html#Troubleshooting?
nbconvert
correctly renders the page with the figure (usingjupyter nbconvert --to html ipympl-lab-test.ipynb
)
I'm still wondering why nbconvert
shows the plot even without widget state.
I think it would be useful to document this - it took me a little while to find this 'widget state' option. Not sure when this was introduced.
I could not see the difference between the notebook saved with and without. As to how nbconvert
manages to render -no idea, I guess there should be a way to catch an error and switch to the png automatically, but that's beyond my area of expertise.
Hi I have been using nbsphinx for a couple of years for my library to compile the tutorials from notebooks.
I had to reinstall python and now the figures are not longer showed on the sphinx documentation (they show fine on the jupyter notebooks with
%matplotlib widget
).If I run the command:
python -c "import sys; print('\n',sys.version); import ipympl; print('ipympl version:', ipympl.__version__)" && jupyter --version && jupyter nbextension list && jupyter labextension list
I get
ipympl version: 0.9.3 Selected Jupyter core packages... IPython : 8.23.0 ipykernel : 6.29.4 ipywidgets : 8.1.2 jupyter_client : 8.6.1 jupyter_core : 5.7.2 jupyter_server : 2.13.0 jupyterlab : 4.1.6 nbclient : 0.10.0 nbconvert : 7.16.3 nbformat : 5.10.4 notebook : 7.1.2 qtconsole : 5.5.1 traitlets : 5.14.2 Known nbextensions: config dir: /home/vital/anaconda3/etc/jupyter/nbconfig notebook section jupyter-matplotlib/extension enabled
I am using ubuntu 22.04.04 with python 3.11 and these are some of the packages I have installed:
docutils 0.20.1 ipympl 0.9.3 ipython 8.23.0 jupyter 1.0.0 jupyter_client 8.6.1 jupyter-console 6.6.3 jupyter-contrib-core 0.4.2 jupyter-contrib-nbextensions 0.7.0 jupyter_core 5.7.2 jupyter-events 0.10.0 jupyter-highlight-selected-word 0.2.0 jupyter-lsp 2.2.5 jupyter-nbextensions-configurator 0.6.3 jupyter_server 2.13.0 jupyter_server_terminals 0.5.3 jupyterlab 4.1.6 jupyterlab_pygments 0.3.0 jupyterlab_server 2.26.0 jupyterlab_widgets 3.0.10 matplotlib 3.7.2 matplotlib-inline 0.1.6 mplcursors 0.5.2 nbclient 0.10.0 nbconvert 7.16.3 nbformat 5.10.4 nbsphinx 0.9.2 notebook 7.1.2 notebook_shim 0.2.4 numpy 1.24.4 pip 24.0 scipy 1.10.1 Sphinx 7.2.6 sphinx-rtd-theme 2.0.0 sphinxcontrib-applehelp 1.0.8 sphinxcontrib-devhelp 1.0.6 sphinxcontrib-htmlhelp 2.0.5 sphinxcontrib-jquery 4.1 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.7 sphinxcontrib-serializinghtml 1.1.10
Thank you very much for any advice.