bokeh / jupyter_bokeh

An extension for rendering Bokeh content in JupyterLab notebooks
BSD 3-Clause "New" or "Revised" License
253 stars 48 forks source link

"semver range ^2.0.0 is not registered as a widget module" when use `BokehModel` class #97

Closed ruoyu0088 closed 4 years ago

ruoyu0088 commented 4 years ago

After updated to jupyter lab 2.0.0 the following code raises javascript exception:

from bokeh.plotting import figure
import jupyter_bokeh as jb
fig = figure(height=200, width=300)
fig_widget = jb.BokehModel(fig)

installed extensions:

   app dir: C:\Miniconda3\share\jupyter\lab
        @bokeh/jupyter_bokeh v2.0.0 enabled  ok
        @jupyter-widgets/jupyterlab-manager v2.0.0 enabled  ok
        @jupyterlab/toc v3.0.0 enabled  ok
        @mohirio/jupyterlab-horizon-theme v2.0.0 enabled  ok
        @pyviz/jupyterlab_pyviz v1.0.0 enabled  ok

the error log is:

manager-base.js:274 Could not instantiate widget
(anonymous) @ manager-base.js:274
l @ manager-base.js:45
(anonymous) @ manager-base.js:26
s @ manager-base.js:18
Promise.then (async)
l @ manager-base.js:19
(anonymous) @ manager-base.js:20
Rtm6.L @ manager-base.js:16
e._make_model @ manager-base.js:258
(anonymous) @ manager-base.js:247
l @ manager-base.js:45
(anonymous) @ manager-base.js:26
(anonymous) @ manager-base.js:20
Rtm6.L @ manager-base.js:16
e.new_model @ manager-base.js:233
e.handle_comm_open @ manager-base.js:145
C._handleCommOpen @ manager.js:63
_handleCommOpen @ default.js:981
async function (async)
_handleCommOpen @ default.js:980
_handleMessage @ default.js:1123
async function (async)
_handleMessage @ default.js:1087
(anonymous) @ default.js:94
Promise.then (async)
_onWSMessage @ default.js:91
utils.js:119 Error: Could not create a model.
    at n (utils.js:119)
    at async C._handleCommOpen (manager.js:62)
    at async m._handleCommOpen (default.js:980)
    at async m._handleMessage (default.js:1122)
n @ utils.js:119
Promise.catch (async)
e.handle_comm_open @ manager-base.js:150
C._handleCommOpen @ manager.js:63
_handleCommOpen @ default.js:981
async function (async)
_handleCommOpen @ default.js:980
_handleMessage @ default.js:1123
async function (async)
_handleMessage @ default.js:1087
(anonymous) @ default.js:94
Promise.then (async)
_onWSMessage @ default.js:91
default.js:987 Exception opening new comm
_handleCommOpen @ default.js:987
async function (async)
_handleCommOpen @ default.js:980
_handleMessage @ default.js:1123
async function (async)
_handleMessage @ default.js:1087
(anonymous) @ default.js:94
Promise.then (async)
_onWSMessage @ default.js:91
default.js:99 Error: Module @bokeh/jupyter_bokeh, semver range ^2.0.0 is not registered as a widget module
    at C.loadClass (manager.js:319)
    at C.<anonymous> (manager-base.js:264)
    at l (manager-base.js:45)
    at Object.next (manager-base.js:26)
    at manager-base.js:20
    at new Promise (<anonymous>)
    at Rtm6.L (manager-base.js:16)
    at C.e._make_model (manager-base.js:258)
    at C.<anonymous> (manager-base.js:247)
    at l (manager-base.js:45)
mattpap commented 4 years ago

It should work given this setup, though there may be a variety of reasons for it to fail. I would start from making sure that there is no environment mismatch between jupyterlab you are running and where of extensions were installed (this is a surprisingly common issue, where people are mixing software from different environments). Otherwise, extensions may need a rebuild (jupyter lab build). If this doesn't help, we will investigate further.

ruoyu0088 commented 4 years ago

I rebuilded jupyterlab by following command, but the same error occurred.

jupyter lab clean
jupyter lab build

Then I uninstalled jupyterlab, removed the jupyter folder in the share path, and installed jupyterlab and the extensions again. It works now.