1

I'm using a custom widget in Jupyter. After upgrading to a new machine it stopped functioning. Checking the javascript console in the browser window running the notebook I see the error ReferenceError: _ is not defined. Indeed, running the following in a Jupyter cell:

%%js
alert(_)

I get the same error. Doing the exact same command on my other machine functions correctly (it shows the definition of _ as in underscore.js). The html source of the Jupyter Notebook still shows underscore.js as being specified in the require.config. Note that simple included widgets still function as expected (so it is not an issue with initializing the widget system).

I haven't found anything in the changelogs of ipywidgets or jupyter regarding changes to the use of underscore.js. I know that the widget api has changed recently in ipywidgets8.0, which is why I am still using version 7.7.3.

Does anyone know if this is an expected change of behaviour in how widgets work? Any other ideas of why underscore does not seem to be initialized properly?

John
  • 723
  • 1
  • 5
  • 12
  • 1
    I encountered the same error. `pip install notebook==6.4.11` is the last version that worked for me. It seems like js assets were delegated to NbClassic since 6.5.x: see https://github.com/jupyter/notebook/pull/6474. – obk Apr 21 '23 at 23:45
  • Thanks for that link. I'm on `notebook==6.4.12` and that also works. So it looks like the 6.5.x branch might have broken this. – John Apr 23 '23 at 21:07
  • Downgrading on my other machine to 6.4.12 fixed the issue. @obk if you leave an answer I will accept it as it resolved my issue. – John Apr 25 '23 at 09:24

1 Answers1

1

Underscore.js is available in the 6.4.x series e.g. pip install notebook=6.4.12

It broke in your case likely because js assets were delegated to NbClassic starting with 6.5, which I'm guessing doesn't load underscore.js (or doesn't make it available to the notebook frontend). See github.com/jupyter/notebook/pull/6474.

obk
  • 488
  • 5
  • 12