SageMath and interact / ipywidgets with jupyter
I got the SageMath kernel working well inside my anaconda distribution's copy of jupyter, following these instructions, so I can open SageMath notebooks using anaconda jupyter and they run perfectly fine -- almost.
I would like to get interact elements / ipywidgets working when I use SageMath as a kernel in anaconda jupyter, but with my current configuration (hopefully described in sufficient detail below), I get the following error message in the console
[IPKernelApp] WARNING | Widget Javascript not detected. It may not be installed or enabled properly.
and the notebook simply outputs the initial value of the function with no interactivity.
I'm running SageMath 8.1 on macOS. I've been able to get interact elements and ipywidgets with SageMath code running in the SageMath jupyter notebook interface (not sure if this was necessary, but I ran
/local/bin/jupyter nbextension enable --py widgetsnbextension
in the SageMath directory.) Everything works as expected, i.e. if I run sagemath -n jupyter
and open a notebook containing:
import ipywidgets as widgets
widgets.IntSlider( value=7, min=0, max=10, step=1, description='Test:', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d' )
I get a slider widget which works.
Similarly, examples from this interact tutorial on the SageMath wiki run perfectly fine in SageMath jupyter.
I also have an up-to-date anaconda install of jupyter where the ipywidgets nbextension has been enabled; the above ipywidgets code can be run in anaconda jupyter with the ordinary python kernel and works fine.
[The real reason I am asking this question is I would like to figure out how to get interactive widgets working in jupyterlab with the SageMath kernel, but I'm guessing that if the above question can be answered, I can get everything else working as well.]
Just something to try: does the working directory make a difference? Could you try running the Sage-Jupyter-in-anaconda from the Sage root directory?