12

Question: I installed python3 and jupyter notebook using pip3 in MacOs 10.9.
When I try to run the widget it gives error that there is no javascript widget. I have python3 and R kernels installed in Jupyter-notebook.

Code:

from ipywidgets import widgets
from IPython.display import display
text = widgets.Text()
display(text)
text.on_submit('hello')

Error:

Widget Javascript not detected.  It may not be installed or enabled properly.  

Attempts:

sudo -H pip3 install ipywidgets  
sudo -H pip3 install -upgrade ipywidgets  
jupyter nbextension enable --py widgetsnbextension
# restarted the computer. 

The last command gives error.

[EnableNBExtensionApp] CRITICAL | Bad config encountered during initialization:
[EnableNBExtensionApp] CRITICAL | Unrecognized flag: '--py'

Note that in mac I have jupyter-nbextension command but the command:

jupyter-nbextension enable --py widgetsnbextension 

does not work either.

But jupyter nbextension enable widgetsnbextension gives no error and also does nothing. The same error is popped in if I run the code.

Also,

import ipywidgets
ipywidgets.__version__

gives '6.0.0'.

Some notes:

which jupyter  
jupyter is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
which jupyter-notebook
jupyter-notebook is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter-notebook

Related links:

https://github.com/jupyter-widgets/ipywidgets/issues/541    
https://github.com/jupyter/help/issues/32    
https://github.com/jupyter/help/issues/131    
https://github.com/binder-project/binder/issues/83   

How can I install widgets?
Do I need to install java separately ?

BhishanPoudel
  • 1
  • 15
  • 87
  • 137
  • Answered here (bad news -- ipywidgets not supported by PyCharm): https://stackoverflow.com/questions/41106767/pycharm-notebook-widget-javascript-not-detected – Eugene Belogay Jul 18 '17 at 21:22

5 Answers5

7

Run the following command: jupyter nbextension enable --py --sys-prefix widgetsnbextension, then restart the kernel in Jupyter should do the trick.

chjortlund
  • 3,026
  • 29
  • 28
  • 4
    Enabling notebook extension is SUCCESSFUL, but , however, the module widgets still gives the error: Widget Javascript not detected. It may not be installed or enabled properly. Can we also solve WIDGETS problem??? – BhishanPoudel May 05 '17 at 15:15
  • Your not just missing the ipywidgets? Try installing it by running: pip install ipywidgets – chjortlund May 10 '17 at 13:52
  • 1
    Thanks @chjortlund, `pip install ipywidgets ` helped for me – maria Oct 20 '20 at 22:56
4

I used the following commands successfully with Jupyter, Mac OS, Python 3.6, and Anaconda. The first command gets the latest version of ipywidgets at this time (version 7.0).

conda install -c conda-forge ipywidgets

jupyter nbextension enable --py widgetsnbextension
stackoverflowuser2010
  • 34,189
  • 37
  • 159
  • 200
1

I faced the same problem and after running the command:jupyter nbextension enable --py --sys-prefix widgetsnbextension, the prompt should appear:

>Enabling notebook extension jupyter-js-widgets/extension...

- Validating: ok. Refresh your jupyter notebook and the widgets worked.

1

Probably the best way, at least it worked for me: reinstall the ipywidgets and widgetsextension and it should work.

pip uninstall ipywidgets widgetsnbextension

pip install ipywidgets

jupyter nbextension enable --py --sys-prefix widgetsnbextension
Adarsh Trivedi
  • 546
  • 1
  • 8
  • 20
1

This solved it for me:

jupyter labextension install @jupyter-widgets/jupyterlab-manager
Vikash Madhow
  • 1,162
  • 9
  • 14