☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Error: Model 'Div' does not exist. This could be due to a widget or a custom model not being registered before first usage

Community Support
blockhart
blockhart

Hello,

Bokeh widgets including Div, PreText, and Paragraph are not rendering in a jupyter notebook in VS Code or a browser.

Example:

from bokeh.io import show
from bokeh.models import Div

div = Div(text="text")
show(div)

Stack traceback:

Error: Model 'Div' does not exist. This could be due to a widget or a custom model not being registered before first usage.
    at Object.s.Models (https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js:163:190)
    at Function._instantiate_object (https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js:162:5089)
    at Function._instantiate_references_json (https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js:162:5239)
    at Function.from_json (https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js:162:8384)
    at Object.t.embed_items_notebook (https://cdn.bokeh.org/bokeh/release/bokeh-2.0.2.min.js:555:1533)
    at embed_document (eval at runCodeHere (vscode-resource://file///Users/brandonlockhart/.vscode/extensions/ms-python.python-2020.5.80290/out/datascience-ui/notebook/vendors~nteract_transforms.bundle.js:2:11583), <anonymous>:6:20)
    at eval (eval at runCodeHere (vscode-resource://file///Users/brandonlockhart/.vscode/extensions/ms-python.python-2020.5.80290/out/datascience-ui/notebook/vendors~nteract_transforms.bundle.js:2:11583), <anonymous>:10:5)
    at eval (eval at runCodeHere (vscode-resource://file///Users/brandonlockhart/.vscode/extensions/ms-python.python-2020.5.80290/out/datascience-ui/notebook/vendors~nteract_transforms.bundle.js:2:11583), <anonymous>:26:3)
    at runCodeHere (vscode-resource://file///Users/brandonlockhart/.vscode/extensions/ms-python.python-2020.5.80290/out/datascience-ui/notebook/vendors~nteract_transforms.bundle.js:2:11583)
    at t.value (vscode-resource://file///Users/brandonlockhart/.vscode/extensions/ms-python.python-2020.5.80290/out/datascience-ui/notebook/vendors~nteract_transforms.bundle.js:2:12015)

Software version info:

  • bokeh: 2.0.2
  • python: 3.7.4
  • jupyter: 1.0.0
  • vscode: 1.45.1
  • chrome: 83.0.4103.61
  • OS: macos 10.15.5

Screenshot:

⌁   Link to post
Bryan
Bryan

You are not calling output_notebook for a start:

That said, things still work fine for me without output_notebook, they just cause the output to be a separate HTML file shown in a new tab (as expected).

The proximate cause of the error is that widget implementations are split in to a separate bokeh-widgets-2.0.2.min.js bundle, and your browser has not loaded this file. But Bokeh always automatically includes extra bundles when they are needed by default, so more information would be necessary to try and understand what is preventing that from happening in your specific situation.

⌁   Link to post
Bryan
Bryan

Any other messages on the JS console? Any information in the browser network debug pane? I’m afraid I’m somewhat at a loss. You could also try using inline resources instead of default loading from CDN.

⌁   Link to post
Bryan
Bryan

We 100% set the header (permissively) on CDN if the SRI attrs (e.g. crossorigin="anonymous") are on the request:

But what can has been observed is that if a browser first loads BokehJS without the SRI attributes (for any reason), then a subsequent load with them set can fail. This is due to a particular interpretation Chrome’s makes wrt SOP and caching that many people regard as a bug in Chrome. [1] I have not observed or heard of it anywhere but Chrome, though. [2]

There are some spots in the docs that failed to set the SRI hashes, so that made it too easy to trigger this situation for users that viewed the affected pages first. But as of the upcoming release, every place I can think of should be properly setting the SRI attributes, so someone would have to really go out of their way to have them loaded without.

TLDR; all I can suggest right now is to clear cache / force reload or use inline resources.


  1. All the gory details for anyone that wants to see them:

    67743 - chromium - An open-source project to help move the web forward. - Monorail ↩︎

  2. I guess it’s possible this is version-dependent. I definitely explicitly tried—but failed—to repro this scenario on FF and Safari. I could only make this happen on Chrome. ↩︎

⌁   Link to post
Bryan
Bryan

I guess I should add: I am speculating that the above is what is going on in this particular situation. I can’t think of any other reason, because the only way I know that the header could be missing is that it is being loaded out of cache (without it having been set previously when it was put there).

⌁   Link to post

End of archived discussion · Replies are disabled