Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter notebook: Widget Javascript not detected

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 ?

like image 808
BhishanPoudel Avatar asked May 03 '17 20:05

BhishanPoudel


People also ask

Does Jupyter notebook support Javascript?

Jupyter Notebooks are documents that contain a mix of live code (Python, R, Julia, JavaScript, and more), visualizations, and narrative text (Markdown). They're useful for breaking down concepts in a story telling form, where you can give some context and show the code below along with interactive visualizations.

How do I import Ipywidgets in Jupyter notebook?

Installing in classic Jupyter NotebookInstall the widgetsnbextension package in the environment containing the Jupyter Notebook server. Install ipywidgets in each kernel's environment that will use ipywidgets.


1 Answers

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.

like image 60
Lucas Igor Balthazar Avatar answered Oct 22 '22 11:10

Lucas Igor Balthazar