jupyter-widgets / ipydatagrid

Fast Datagrid widget for the Jupyter Notebook and JupyterLab
BSD 3-Clause "New" or "Revised" License
579 stars 51 forks source link

Issues when using ipydatagrid with Mercury / nbconvert #338

Closed pplonski closed 2 years ago

pplonski commented 2 years ago

The Mercury is a framework for converting Jupyter Notebooks into web applications with YAML header. It is based on the nbconvert tool. It collects parameters from the user interface and executes the notebook with new parameters with nbconvert. The final HTML is displayed in the web browser for the user.

One of my users has an issue with the ipydatagrid package. Details https://github.com/mljar/mercury/issues/159

He is using the following code:

from ipydatagrid import DataGrid
import numpy as np 
import pandas as pd 

df = pd.DataFrame(data=np.random.randn(5,10))
datagrid=DataGrid(df)
datagrid

Is the ipydatagrid working with the nbconvert tool? Can I export notebooks with ipydatagrid to HTML files? When I tried the above code, I got:

image

The notebook was exported with the command:

jupyter notebook --to html grid.ipynb

If the ipydatagird will work with nbconvert, it will work with Mercury as well.

jonyow commented 2 years ago

I've also run into the same issue, with ipydatagrid not rendering with Jupyter Notebooks exported to HTML. It did also used to work for me until recently.

The notebook was exported using: jupyter nbconvert --to html

This was the error I get:

Failed to create view for 'DataGridView' from module 'ipydatagrid' with model 'DataGridModel' from module 'ipydatagrid' TypeError: c.JupyterPhosphorPanelWidget is not a constructor at g._createElement (https://cdn.jsdelivr.net/npm/ipydatagrid@%5E1.1.11/dist/index.js:2:997709)

Any help would be much appreciated!

ibdafna commented 2 years ago

Thank you for reporting - we will investigate!

martinRenou commented 2 years ago

Failed to create view for 'DataGridView' from module 'ipydatagrid' with model 'DataGridModel' from module 'ipydatagrid' TypeError: c.JupyterPhosphorPanelWidget is not a constructor

It's probably pulling ipywidgets 8?

jonyow commented 2 years ago

If it helps, I'm using ipywidgets 7.7.0 when encountering the error above.

martinRenou commented 2 years ago

Just in case, can you try with 7.7.2? I wonder if there is an issue with older ipywidgets that could be pulling the front-end HTMLManager for ipywidgets 8 which would be incompatible.

jonyow commented 2 years ago

it's the same on 7.7.2:

image

martinRenou commented 2 years ago

I was wrong, it's actually independent from the ipywidgets version you have locally, it only depends on which HTMLManager version nbconvert pulls (by default the latest)

So can you try running nbconvert with the option --HTMLExporter.html_manager_semver_range="0.20.2"?

jonyow commented 2 years ago

yes, that's working for me now! Thanks very much for the quick response and for open sourcing such an useful package!