mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
761 stars 56 forks source link

Fix itables on Jupyter Lab #3

Closed mwouts closed 2 years ago

mwouts commented 5 years ago

In Jupyter lab, importing itables yields an error: Javascript Error: require is not defined.

mwouts commented 5 years ago

Apparently we'll have to create a widget for using itables in Jupyter Lab. An example on how to develop a new widget is available at https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Custom.html (the example only works in the classical notebook).

fcollonval commented 4 years ago

A small fix for JupyterLab.

Cell to add at the beginning of the notebook in JupyterLab

from IPython.display import HTML, display
from time import sleep

display(HTML("""
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
"""))

sleep(0.1)

import itables.interactive
mwouts commented 4 years ago

Thank you @fcollonval for the code snippet, much appreciated!

jkochel commented 3 years ago

the snipped stopped working unfortunately, I am getting a following error an empty table and a following error in the console:

Screenshot 2021-09-03 at 14 14 02
mwouts commented 2 years ago

I have added a mention of the workaround in the README. From the version 0.3.1 on, jquery is loaded by itables, so the workaround can be reduced to this:

from IPython.display import HTML, display
from time import sleep

display(HTML("""
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
"""))

sleep(0.1)

@jkochel , I have also changed the way we use jquery. May I ask you to give a try to the new version 0.3.1 and report if the problem that you had in September with version 0.3.0 is still present? Thanks

mwouts commented 2 years ago

This has been solved in itables==0.4.0 (to be released soon)