-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Description
When executing cells that generate interactive Plotly visualizations in a VS Code notebook connected to a Colab runtime, the figures fail to render and display a JavaScript error instead. This completely breaks interactive exploratory data analysis workflows that depend on Plotly's hover, zoom, and interactive features.
Error Message:
Error rendering output item using 'jupyter-ipywidget-renderer': i is not a function
Environment
- VS Code version: 1.96.0
- Colab extension version: 0.0.16 (latest as of Dec 2025)
- Jupyter extension version: 2024.11.0
- OS: Windows 11
- Python version: 3.10.12 (Colab default)
- Plotly version: 5.24.1
Reproduction Steps
- Connect VS Code to a Colab runtime (CPU or GPU)
- Create a new notebook cell with this minimal example:
import plotly.graph_objects as go
fig = go.Figure(data=go.Scatter(x=[1, 2, 3], y=[4, 5, 6]))
fig.show()- Execute the cell
- Observe the error instead of the interactive plot
Expected Behavior
The Plotly figure should render as an interactive visualization with hover tooltips, zoom controls, and pan functionality, just like it does in:
- Native Google Colab web interface
- Local VS Code with local Jupyter kernels
- JupyterLab
Actual Behavior
The cell output shows:
Error rendering output item using 'jupyter-ipywidget-renderer': i is not a function
The figure does not render at all.
Workarounds Attempted (None Successful)
I've tried multiple approaches to fix this, all unsuccessful:
1. Changing Plotly renderers:
import plotly.io as pio
pio.renderers.default = 'colab' # No effect
pio.renderers.default = 'iframe' # No effect
pio.renderers.default = 'plotly_mimetype' # ✓ WORKS!2. Installing ipywidgets explicitly:
!pip install ipywidgets==8.1.53. Using static renderers (works but defeats purpose):
pio.renderers.default = 'png' # Works but produces static images only4. Saving to HTML and displaying:
fig.write_html('temp.html')
from IPython.display import IFrame
IFrame('temp.html', width=800, height=600)This displays the chart but requires manual file downloads and breaks the notebook workflow.
Impact
This creates unnecessary friction for data science and ML workflows because:
- Users expect Plotly to "just work" like it does in native Colab
- The default renderer fails with a cryptic error message
- Users must discover the non-obvious
plotly_mimetypeworkaround - Every notebook needs manual renderer configuration at the top
- Breaks compatibility with notebooks written for native Colab (they use default renderer)
User Experience Issue:
When migrating from native Colab to VS Code + Colab extension, users hit this error immediately and may assume Plotly doesn't work at all, rather than discovering the workaround.
Additional Context
- This works perfectly in the native Colab web interface
- This works with local VS Code + local Jupyter kernels
- Other visualizations (matplotlib, seaborn) work fine with the Colab extension
- The issue appears to be specific to widget-based interactive outputs (Plotly, ipywidgets)
Suggested Fix
Since plotly_mimetype works, the extension should either:
Option 1 (Preferred): Auto-configure the correct renderer
- Detect when connected to Colab runtime
- Automatically set
plotly.io.renderers.default = 'plotly_mimetype' - Make Plotly work "out of the box" like in native Colab
Option 2: Fix the default renderer
- Investigate why the default ipywidget renderer fails
- Ensure compatibility with Colab's widget implementation
- This would benefit other interactive libraries too (ipywidgets, altair, etc.)
Option 3 (Minimum): Documentation
- Add a troubleshooting section to the README
- Document the
plotly_mimetypeworkaround - Include example setup cell for notebooks
Related Issues
- A handful of
google.colablibraries (e.g.drive.mountanduserdate.get) are unsupported (for now!) #215 mentionsgoogle.colablibrary incompatibilities (userdata, drive.mount) - Similar widget rendering issues might affect other interactive libraries (ipywidgets, altair, bokeh)