question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Widgets not displaying in notebook

See original GitHub issue

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

When trying to use interactive plots in a notebook via %matplotlib widget, no plot is shown in the output. For example, this code fails:

%matplotlib widget
import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4, 5])

This appears to be an interaction with the widget sources. If I have the following option configured in my settings:

"jupyter.widgetScriptSources": [ "jsdelivr.com", "unpkg.com" ],

then no plots appear and errors arise (shown in the Jupyter Output logs below). However, if I delete that setting, the plots appear and work as expected.

This problem has only appeared in the last one or two weeks, and before that I did not experience any issues.

VS Code Version

1.71.0

Jupyter Extension Version

v2022.8.1002431955

Jupyter logs

info 12:2:41.952: Started kernel default_venv (Python 3.8.10)., (Raw session started and connected)
info 12:2:41.953: Finished connecting 7b30d229-8a05-4f19-8fdb-93aaeabacf05
info 12:2:41.994: UpdateWorkingDirectoryAndPath in Kernel
info 12:2:41.994: Executing silently Code (busy) = import os\nimport sys\n%cd "//home/wheels2050/devel/scratch"\nif os.getcwd() not in sys.path:\nsys.path
info 12:2:42.367: Executing silently Code (completed) = import os\nimport sys\n%cd "//home/wheels2050/devel/scratch"\nif os.getcwd() not in sys.path:\nsys.path with 1 output(s)
info 12:2:42.369: Waiting for idle on (kernel): 28696b6e-6d2c-4ed3-8cab-fd079dbfc5af -> idle
info 12:2:42.369: Finished waiting for idle on (kernel): 28696b6e-6d2c-4ed3-8cab-fd079dbfc5af -> idle
info 12:2:42.384: Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
info 12:2:42.385: Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
info 12:2:42.407: Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
info 12:2:42.407: Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
info 12:2:42.407: Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/home/wheels2050/.vscode/extensions/ms-toolsai.jupyter-2022.8.1002431955/tmp/scripts/40e9f355505ee45e308aaa67dbba9888d0afda3afe9284e655b8e00c43fceaa5/jupyter
info 12:2:42.407: Widget Message: data-base-url set to https://file%2B.vscode-resource.vscode-cdn.net/home/wheels2050/.vscode/extensions/ms-toolsai.jupyter-2022.8.1002431955/tmp/scripts/40e9f355505ee45e308aaa67dbba9888d0afda3afe9284e655b8e00c43fceaa5/jupyter
info 12:2:45.266: Execute Cell 0 /home/wheels2050/devel/scratch/bar.ipynb
info 12:2:46.903: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
info 12:2:46.921: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
info 12:2:46.970: Widget Message: WidgetManager: Loading class MPLCanvasModel:jupyter-matplotlib:^0.11
info 12:2:46.970: Widget Message: Fetch IPyWidget source for jupyter-matplotlib
info 12:2:46.971: Fetch Script for {"moduleName":"jupyter-matplotlib","moduleVersion":"^0.11","requestId":"jupyter-matplotlib:^0.11:1662690766926"}
info 12:2:46.971: Fetch Script for jupyter-matplotlib
info 12:2:46.972: Searching for Widget Script jupyter-matplotlib#^0.11 using cdns jsdelivr.com unpkg.com
info 12:2:47.337: Cell 0 executed with state Success
info 12:2:47.480: Widget Message: Waiting for model to be available before rendering it 433d37f97dbe4b46bffa927bbdcf4622
info 12:2:48.175: Widget Script jupyter-matplotlib#^0.11 found at URI: https://unpkg.com/jupyter-matplotlib@^0.11/dist/index
info 12:2:48.176: Script source for Widget jupyter-matplotlib@^0.11 was found from source cdn
info 12:2:48.176: Script for jupyter-matplotlib, is https://unpkg.com/jupyter-matplotlib@^0.11/dist/index from cdn
info 12:2:48.181: Widget Message: Received IPyWidget scripts [{"moduleName":"jupyter-matplotlib","scriptUri":"https://unpkg.com/jupyter-matplotlib@^0.11/dist/index","source":"cdn"}]
info 12:2:48.181: Widget Message: Source for IPyWidget jupyter-matplotlib found in cdn @ https://unpkg.com/jupyter-matplotlib@^0.11/dist/index.
info 12:2:48.181: Widget Message: Registering IPyWidget jupyter-matplotlib found in https://unpkg.com/jupyter-matplotlib@^0.11/dist/index.
info 12:2:48.196: Fetch Script for jupyter-matplotlib
info 12:2:48.197: Script source for Widget jupyter-matplotlib@^0.11 was found from source cdn
info 12:2:48.197: Script for jupyter-matplotlib, is https://unpkg.com/jupyter-matplotlib@^0.11/dist/index from cdn
info 12:2:48.218: Widget Message: Received IPyWidget scripts [{"moduleName":"jupyter-matplotlib","scriptUri":"https://file%2B.vscode-resource.vscode-cdn.net/home/wheels2050/.vscode/extensions/ms-toolsai.jupyter-2022.8.1002431955/tmp/scripts/40e9f355505ee45e308aaa67dbba9888d0afda3afe9284e655b8e00c43fceaa5/jupyter/nbextensions/jupyter-matplotlib/index","source":"local"}]
info 12:2:48.219: Widget Message: Received IPyWidget scripts [{"moduleName":"jupyter-matplotlib","scriptUri":"https://unpkg.com/jupyter-matplotlib@^0.11/dist/index","source":"cdn"}]
info 12:2:48.829: Widget Message: WidgetManager: failed, Loading class MPLCanvasModel:jupyter-matplotlib:^0.11
info 12:2:48.829: Widget Message: WidgetManager: failed, Loading class MPLCanvasModel:jupyter-matplotlib:^0.11
error 12:2:48.830: Widget load failure {} {
  className: 'MPLCanvasModel',
  moduleName: 'jupyter-matplotlib',
  moduleVersion: '^0.11',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 12:2:48.834: Widget Message: WidgetManager: Loading class MPLCanvasModel:jupyter-matplotlib:^0.11
info 12:2:48.839: Widget Message: WidgetManager: failed, Loading class MPLCanvasModel:jupyter-matplotlib:^0.11
info 12:2:48.839: Widget Message: WidgetManager: failed, Loading class MPLCanvasModel:jupyter-matplotlib:^0.11
error 12:2:48.839: Widget load failure {} {
  className: 'MPLCanvasModel',
  moduleName: 'jupyter-matplotlib',
  moduleVersion: '^0.11',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 12:2:48.841: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
warn 12:2:48.843: StdErr from Kernel Process [IPKernelApp] WARNING | No such comm: 433d37f97dbe4b46bffa927bbdcf4622

info 12:2:48.879: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
info 12:2:48.880: Widget Message: WidgetManager: Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.915: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.915: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
error 12:2:48.915: Widget load failure {} {
  className: 'ToolbarModel',
  moduleName: 'jupyter-matplotlib',
  moduleVersion: '^0.11',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 12:2:48.915: Widget Message: WidgetManager: Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.915: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.915: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
error 12:2:48.916: Widget load failure {} {
  className: 'ToolbarModel',
  moduleName: 'jupyter-matplotlib',
  moduleVersion: '^0.11',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 12:2:48.917: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
info 12:2:48.917: Widget Message: WidgetManager: Loading class LayoutModel:@jupyter-widgets/base:1.2.0
info 12:2:48.918: Widget Message: WidgetManager: Loading class ToolbarModel:jupyter-matplotlib:^0.11
warn 12:2:48.957: StdErr from Kernel Process [IPKernelApp] WARNING | No such comm: 147930f96d844b81b3cb4265cbabd338

info 12:2:48.957: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.957: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
error 12:2:48.957: Widget load failure {} {
  className: 'ToolbarModel',
  moduleName: 'jupyter-matplotlib',
  moduleVersion: '^0.11',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 12:2:48.959: Widget Message: WidgetManager: Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.959: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
info 12:2:48.959: Widget Message: WidgetManager: failed, Loading class ToolbarModel:jupyter-matplotlib:^0.11
error 12:2:48.959: Widget load failure {} {
  className: 'ToolbarModel',
  moduleName: 'jupyter-matplotlib',
  moduleVersion: '^0.11',
  cdnsUsed: false,
  isOnline: true,
  timedout: false,
  error: '{}'
}
info 12:2:48.961: Widget Message: Received display data message 433d37f97dbe4b46bffa927bbdcf4622
info 12:2:48.961: Widget Message: Error: Failed to render widget 433d37f97dbe4b46bffa927bbdcf4622, Error: Module jupyter-matplotlib, semver range ^0.11 is not registered as a widget module
info 12:2:48.961: Widget Message: Received display data message 433d37f97dbe4b46bffa927bbdcf4622
warn 12:2:48.971: StdErr from Kernel Process [IPKernelApp] WARNING | No such comm: 7792cf82f53c49e79b821b71367c4717

Coding Language and Runtime Version

Python v3.8.10

Language Extension Version (if applicable)

v2022.14.0

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
DonJayamannecommented, Oct 9, 2022

@mapio IPyWidgets 8 is not yet supported, see https://github.com/microsoft/vscode-jupyter/issues/8552

0reactions
DonJayamannecommented, Dec 5, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

IPython Notebook ipywidgets does not show - Stack Overflow
After running jupyter --version inside my conda environment, i saw this. After restarting my kernel, the widgets appeared just fine. I hope ...
Read more >
Jupyter notebook widgets not displaying - Jetson Nano
I have a Nano with a fresh Jetpack 4.5.1 on and Docker container l4t-ml:r32.5.0-py3. When i use widgets like: import ipywidgets as widgets...
Read more >
Azure ml notebook does not show widgets from ipywidgets
Azure ml notebook does not show widgets from ipywidgets. ipywidgets seems to work fine for the simplest usages, i.e. just using a slider....
Read more >
Why does the Output context manager not show the desired ...
Doesn't display the widget. Assigning the output widget to a variable and doing a display(out) as well doesn't work. jupyter --version Selected Jupyter...
Read more >
Embedding Jupyter Widgets in Other Contexts than the ...
In order to clear widget state from the frontend so that it does not show up in the embedding, restart the kernel and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found