Forums

ipython widget not showing

There's an Ipython notebook sampling.ipynb from the repository https://github.com/AllenDowney/CompStats.

This notebook generally works just fine at PythonAnywhere, but with one exception: The ipython slider widget does not display at all.

The code, spread over several cells, is in part:

from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
slider = widgets.IntSlider(min=10, max=1000, value=100)
interact(plot_sample_stats, n=slider, xlim=fixed([55, 95]))

What we see is the plot, but with no visible widget. A check of Developer tools in Chrome showed some error involving widgets.

Some research suggests that maybe there is an ipywidgets version issue (reference: https://github.com/jupyter/notebook/issues/1386#issuecomment-213565839)

pip install ipywidgets==5.0.0
jupyter nbextension enable --py widgetsnbextension

I didn't want to try these for fear of messing up something.

What should I do to get the widget to work?

At the moment javascript widgets don't work in notebooks on PythonAnywhere. We're working on a fix.

Hello,

I am having similar difficulties with installing jupyter-declarativewidgets. It installs fine but fails to be enabled.

jupyter nbextension enable declarativewidgets --py 
    Traceback (most recent call last):
  File "/usr/local/bin/jupyter-nbextension", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 596, in launch_instance
    app.start()
...
    ImportError: No module named declarativewidgets

I was wondering if the issues have been resolved. Thanks.

No. We're still working on that.

Has this been resolved? I am looking into a class that requires this.

Unfortunately not.

Any resolution yet?

No, still none :-(

HI - I assume the same fix would be required for pdvega to work?

jupyter nbextension install --sys-prefix --py vega3

Hmm, it depends on whether it's using widgets -- it might be worth a try, but our best guess is that it probably won't work.