Ipywidgets: Widget Javascript not detected

Created on 15 Jul 2016  Â·  49Comments  Â·  Source: jupyter-widgets/ipywidgets

debugging from notebook

from jupyter_core.paths import jupyter_config_path, jupyter_data_dir, jupyter_runtime_dir, jupyter_path
import jupyter_core.version

!echo !jupyter --version and --path
!jupyter --version
!jupyter --path
!echo

!echo !cat /usr/etc/jupyter/nbconfig/notebook.json
!cat /usr/etc/jupyter/nbconfig/notebook.json
!echo
!echo !ls /usr/local/share/jupyter/nbextensions/jupyter-js-widgets
!ls /usr/local/share/jupyter/nbextensions/jupyter-js-widgets
!echo

print('version:', jupyter_core.version.__version__)
for p in jupyter_config_path():
    print('config:', p)

# list of directories to search for data files...
for p in jupyter_path():
    print('jupyter_path:', p)

print('jupyter_data_dir:', jupyter_data_dir())
print('jupyter_runtime_dir:', jupyter_runtime_dir())

import ipywidgets as widgets
widgets.HTML(value="Hello <b>World</b>")

output

!jupyter --version and --path
4.1.0
config:
    /u/s8weber/.jupyter
    /usr/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /u/s8weber/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /u/s8weber/.local/share/jupyter/runtime

!cat /usr/etc/jupyter/nbconfig/notebook.json
{
  "load_extensions": {
    "jupyter-js-widgets/extension": true
  }
}
!ls /usr/local/share/jupyter/nbextensions/jupyter-js-widgets
extension.js  extension.js.map

version: 4.1.0
config: /u/s8weber/.jupyter
config: /usr/etc/jupyter
config: /usr/local/etc/jupyter
config: /etc/jupyter
jupyter_path: /u/s8weber/.local/share/jupyter
jupyter_path: /usr/local/share/jupyter
jupyter_path: /usr/share/jupyter
jupyter_data_dir: /u/s8weber/.local/share/jupyter
jupyter_runtime_dir: /u/s8weber/.local/share/jupyter/runtime

** Widget Javascript not detected.  It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"

using python3 and jupyterhub.. not sure what next to look at.

Most helpful comment

I don't know about anyone else, but I still see this message ALL THE TIME, on lots of different systems. Sometimes it goes away after running the suggested command, sometimes it doesn't. Sometimes reinstalling ipywidgets helps, sometimes it doesn't. Sometimes it means the widgets aren't working, sometimes it doesn't. Sometimes I manage to get it to go away somehow, but then it comes back the next time anything is upgraded. This message and the associated machinery is really a big pain when using ipywidgets. :-(

All 49 comments

notebook version 4.2.1

/usr/local/lib/python3.5/dist-packages/notebook/_version.py
version_info = (4, 2, 1)

Hi @steverweber thanks for posting.

How did you install ipywidgets? Did you enable the the notebook extension? (jupyter nbextension enable --py widgetsnbextension)

#!/bin/bash

apt-get install -y python3-pip
apt-get install -y nodejs-legacy
apt-get install -y npm
npm install -g configurable-http-proxy
pip3 install setuptools
pip3 install jupyterhub

pip3 install --upgrade jupyterhub
pip3 install --upgrade notebook

#jupyterhub --generate-config

## not sure this is needed?
##npm install jupyter-js-widgets

pip3 install ipywidgets
pip3 install widgetsnbextension
pip3 install --upgrade widgetsnbextension
pip3 install --upgrade ipywidgets
jupyter nbextension enable --py --sys-prefix widgetsnbextension

is npm install jupyter-js-widgets required ?

/etc/jupyterhub_config.py

c = get_config()
c.JupyterHub.ip = '127.0.0.1'
c.JupyterHub.port = 8000
c.Authenticator.admin_users = { 's8weber' }
c.JupyterHub.admin_access = True

also used jupyter nbextension enable --py widgetsnbextension
without --sys-prefix

You should not need to do npm install for a regular install.

humm after clearing out some python2 package ... and what not I get'''

root@jupyter-p01:~# jupyter nbextension enable --py widgetsnbextension
jupyter: 'nbextension' is not a Jupyter command

Hum, this command should come with notebook 4.2.x

i'll give the system a fresh install of ubuntu16.04 and see where that gets us.

I would recommend installing a standalone python distribution like anaconda. This would allow you not to have to nuke your install when you break your python install!

Thanks but I rather stay away from anaconda.. feels too much like a commercial product.
Got a good setup to redeploy systems using pxe boot and saltstack.. so it only took ~10min to nuke and install/configure the jupyter stack on some iron.

root@jupyter-p01:~# /usr/local/bin/jupyter-nbextension enable --py --sys-prefix widgetsnbextension
Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK

but same issue in notebooks...

Widget Javascript not detected.  It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"

Quick question to check if it is a jupyterhub thing: did you try in a standalone notebook server?

cc @epifanio

jupyter-notebook --ip=0.0.0.0
...
import ipywidgets as widgets
widgets.HTML(value="Hello <b>World</b>")

works when without jupyterhub

Hello World
!jupyter --version and --path
4.1.0
config:
    /root/.jupyter
    /usr/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /root/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /root/.local/share/jupyter/runtime


!cat /usr/etc/jupyter/nbconfig/notebook.json
{
  "load_extensions": {
    "jupyter-js-widgets/extension": true
  }
}
!ls /usr/local/share/jupyter/nbextensions/jupyter-js-widgets
extension.js  extension.js.map

version: 4.1.0
config: /root/.jupyter
config: /usr/etc/jupyter
config: /usr/local/etc/jupyter
config: /etc/jupyter
jupyter_path: /root/.local/share/jupyter
jupyter_path: /usr/local/share/jupyter
jupyter_path: /usr/share/jupyter
jupyter_data_dir: /root/.local/share/jupyter
jupyter_runtime_dir: /root/.local/share/jupyter/runtime

guess I'll start diving into the code.

humm this code is not so simple to debug.
/usr/local/lib/python3.5/dist-packages/ipywidgets/widgets/widget.py

got any pointers where i should start?

ok, no need to debug. I think that this is about enabling nbextensions for each jupyterhub user with --user, or with the --sys-prefix argument.

I was under the impression that was fixed... that the users would use the shared.
/usr/etc/jupyter/nbconfig/notebook.json

i did use the --sys-prefix arg

humm its working now.... not sure what changed. I created a new notebook file and it worked in it... humm.. might be tempted to wipe system again and see if the issue can be found.. perhaps the jupyterhub service didnt kill all the runnint ipython kernels... cache ... shrug.

perhaps im not the only one that had an issue where it just starting working after seemingly doing nothing...
https://github.com/ipython/ipywidgets/issues/541

anyways if i hit it again i'll create new issue

It sounds like it might be your browser caching the old javascript? Creating a new notebook might be enough to fetch the new javascript instead of pulling from a local cache.

I thought that aswell... looked at nginx to see if it cached the file... then tried two different web browsers.. had same issue..

perhaps the notebook file includes some hint... o well, i moved on :)

In the future, a good test is to try opening the notebook in incognito mode.

I forgot to mention that the notebook server must be restarted after you
enable the extension.

This might be it.
On Jul 15, 2016 12:29 PM, "Steve Weber" [email protected] wrote:

humm its working now.... not sure what changed. I created a new notebook
file and it worked in it... humm.. might be tempted to wipe system again
and see if the issue can be found.. perhaps the jupyterhub service didnt
kill all the runnint ipython kernels... shrug.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/ipython/ipywidgets/issues/669#issuecomment-233015246,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACSXFkFV6hWIma9eIUdGGsT01GlCZvHTks5qV8NmgaJpZM4JNc_y
.

that's what i did in chrome... but for good coverage also gave firefox a boot.

FWIW, I'm having the same problem with ipython 3

import IPython
IPython.__version__ 

'5.0.0'

pip3 list |grep 'wid*'

ipywidgets (5.2.2)
wcwidth (0.1.7)
widgetsnbextension (1.2.6)

pip3 list |grep 'not*'
command-not-found (0.3)
notebook (4.2.1)
xdiagnose (3.8.4)

attached is a super simple notebook
ipywidgets fail.ipynb.zip

@pleabargain did you run the widget nbextension as per the readme?

I don't know about anyone else, but I still see this message ALL THE TIME, on lots of different systems. Sometimes it goes away after running the suggested command, sometimes it doesn't. Sometimes reinstalling ipywidgets helps, sometimes it doesn't. Sometimes it means the widgets aren't working, sometimes it doesn't. Sometimes I manage to get it to go away somehow, but then it comes back the next time anything is upgraded. This message and the associated machinery is really a big pain when using ipywidgets. :-(

@jbednar +1 for your last comment.
In my case, ipywidgets work perfectly but regularly get the "Widget Javascript not detected..." message when I make call ipywidgets API for the first time in freshly opened notebook. The tools I develop are dedicated to our end-users and this is quite confusing for them.

Hello, I have solved the issue with this:

jupyter nbextension enable --py --sys-prefix widgetsnbextension

cheers!

Great! How?

Oh, did you mean you ran that command and it now works fine for you? That's great, but I run that command often, just in case, and rarely see any improvement from it.

@jbednar - I see this message (it seems) in two types of situations:

(a) when I have messed up my various notebook extension config files and the widget javascript is not available (I haven't installed or enabled it, or I have another config that is overriding something so the javascript is not available). The notebook extension system and overrides can be pretty confusing, and I am messing it up a lot. I finally decided to only install things to sys-prefix, which simplifies it a bit. This situation is outside of the scope of the ipywidgets project, and squarely deals with the notebook extension system.

(b) when I execute cells very quickly after opening a page, and the code maybe executes before the extension loads (@SylvainCorlay has investigated this a bit). I still don't quite understand exactly what the problem is in this situation.

Next time you see this happening, can you drop us a line or open a new issue so we can try to track things down better?

I see the message too. Running the jupyter nbextension command changes nothing, but installing ipywidgets changes the command from suggesting I run the nbextension command to:

Widget Javascript not detected.  It may not be installed or enabled properly.
Unable to render data

I still see this issue frequently but not always, so it does seem to be an asynchronous execution problem as you described in b).

The issue shows up on "Restart kernel and execute all cells", but disappears when each cell is executed by hand, i.e., at human speed....

This issue is fixed in the upcoming 7.0 release. I hope to have a beta out by the end of the week.

I also have this issue with widgetsnbextension 2.0.0 and ipywidgets 6.0.0 in an anaconda environment. I even added a time.sleep(5) on top of the cell which created widgets, to no avail unfortunately. When I load the notebook and the cell executes (it is an initialization cell), the JS will never be loaded, but every time I then run that cell manually again, the JS is loaded and everything works fine. I'll have to add a note for now, telling users of the notebook that they can simply run the cell again to get rid of the problem.

Looking forward to 7.0.0 =)

By the way, an alpha of 7.0 is out now. We're working on getting testing and documentation in much better shape now.

When you run that jupyter nbextension enable --py --sys-prefix widgetsnbextension, do you do that within or outside of some conda environment? Nobody seems to mention this, does it even matter? I've install that "nb_conda" thing to get virtual environments inside jupyter notebook - and I always start jupyter notebook in "root" (i.e. not having activated any virtual environment), instead specifying environment within jupyter notebook. Which is great.

If it isn't obvious, I have no clue of what I am talking about - but after getting this to work after 45 minutes of banging my head on the keyboard, I still don't know where and how I installed or enabled that freakin' widgetsnbextension. Which isn't very satisfying.

BTW: The "browser caches the javascript" might have been one of the culprits with my situation. I opened the devtools/inspector of Chrome (which defaults disables caching), and I immediately progressed from the error message _"Widget Javascript not detected. It may not be installed or enabled properly."_ to the next and equally fascinating _"The installed widget Javascript is the wrong version. It must satisfy the semver range ~2.1.4."_..

@stolsvik, you are describing my entire life in Jupyter. Every day alternates between those two messages, punctuated with an occasional absence of messages that I fail to appreciate at the time.

I personally go as far as clearing my whole jupyter config folders every time when I want reproducible results. I have a script for that, which I'd like to share:

# clearing any old config
rm -rf /home/$user/.jupyter
rm -rf /home/$user/.local/share/jupyter
rm -rf /home/$user/apps/anaconda3/envs/prototype-course/etc/jupyter

# generate base config
jupyter notebook --generate-config

# installing the extensions I want all according to the following method
jupyter nbextension uninstall <extension> --system
jupyter nbextension uninstall <extension> --sys-prefix
jupyter nbextension uninstall <extension> --user
jupyter nbextension install <extension> --symlink --sys-prefix

In my script I have also some commented out stuff, that I do not dare to comment in again to run it, because I don't know if it would disrupt anything in my setup, but some of those lines must have installed the widgets, I guess:

# conda install -c conda-forge --quiet --yes ipywidgets jupyter_contrib_nbextensions
# jupyter contrib nbextension install --sys-prefix
# jupyter nbextension install --py --sys-prefix widgetsnbextension

@stolsvik About running in an env or not: I run this in a conda env. Without that, I think the --symlink in my script is not useful.

Hmm, one oddity I ran into is that the latest JS seems to take a bit of time to load. When I re-ran cells loading ipywidgets, they seemed to work.

One thing that can be helpful is looking at the browser debug pane, to see if jupyter-js-widgets/extension is being loaded. (image hopefully attached below).

image

@gatoatigrado Your console output looks fine to me. The find-and-replace warning is about menu items and has nothing to do with the widgets, I think. I'am not the developer of the widgets though, so I might be wrong. The phenomenon you describe is the same I experience with the widgets. There is a warning inside the notebook, but when I run the cells with the widgets again, the warning disappears and everything works fine.
I did not try version 7.0 yet.

I get this same issue using the latest version of ipywidgets with init_cells nbextensions that runs all the cells on open. Perhaps alluding to this timing issue?

Yes, it is definitely a timing issue. It should be fixed in ipywidgets 7 - can you try the latest 7.0 beta?

Was this page helpful?
0 / 5 - 0 ratings