Plotly Not Showing in Jupyter or VS Code? Renderers Explained

Fix a Plotly chart that doesn't appear: install nbformat, pick the right renderer for Jupyter, VS Code, Colab or a script, and fall back to HTML or PNG output.

If fig.show() raises an error or displays nothing, the usual fixes are to install nbformat in the same environment as your kernel, or to choose a renderer explicitly with fig.show(renderer="...") or pio.renderers.default. The renderer is how Plotly hands the chart to whatever is displaying it.

Quick Example

First check which renderer Plotly picked, then override it:

import plotly.express as px
import plotly.io as pio

print(pio.renderers.default)        # what Plotly chose for this environment

fig = px.bar(x=["Mon", "Tue", "Wed", "Thu", "Fri"], y=[14, 22, 19, 27, 31],
             title="If you can see this, rendering works",
             labels={"x": "Day", "y": "Builds"},
             color_discrete_sequence=["#0284c7"])

pio.renderers.default = "browser"   # or "notebook_connected", "vscode", "colab", "png"
fig.show()

Test bar chart of builds per weekday with the title If you can see this, rendering works

The code and messages here are from Plotly 6.9.

Which Renderer Should I Use?

Where you're running Renderer Notes
JupyterLab or Notebook 7 "plotly_mimetype" (default) or "jupyterlab" Needs nbformat
VS Code notebooks and interactive window "vscode" Needs nbformat and the Jupyter extension
Notebook shared as HTML "notebook_connected" Loads plotly.js from a CDN
Same, but must work offline "notebook" Embeds plotly.js, so the file is much larger
Google Colab "colab" (detected automatically)
Kaggle "kaggle" (detected automatically)
Python script or IPython terminal "browser" Opens a browser tab
Anywhere that only shows images "png" or "svg" Needs kaleido; not interactive
Very large notebooks "iframe" Writes files to iframe_figures/

List every name with print(pio.renderers). A misspelled one raises ValueError: Invalid named renderer(s) received.

ValueError: Mime type rendering requires nbformat>=4.2.0

ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed

The notebook renderers need the nbformat package, which isn't installed along with Plotly. This is true for plotly_mimetype, vscode, notebook and notebook_connected. Install it into the kernel's environment:

pip install --upgrade nbformat      # or: uv add nbformat

Then restart the kernel. If the error stays, the kernel is probably using a different Python from the one you installed into. In a notebook cell, %pip install nbformat installs into the running kernel, and this shows which interpreter that is:

import sys
print(sys.executable)

Blank Output in JupyterLab

If the cell runs without an error but the space is empty:

  1. Upgrade JupyterLab. Plotly 6 requires JupyterLab 3 or later: pip install --upgrade jupyterlab.
  2. Restart the Jupyter server as well as the kernel after upgrading, then reload the browser tab.
  3. Try fig.show(renderer="notebook_connected"). If that works, the problem is the front end's Plotly support and not your figure.
  4. Reopening a saved notebook can show empty cells until you run them again.

A figure also looks blank when it has no data, for example after a filter that matched nothing. print(len(fig.data), fig.data[0].x) rules that out.

Plotly Not Showing in VS Code

  • Install or enable Microsoft's Jupyter extension, which includes the notebook renderers that draw Plotly output.
  • Install nbformat in the environment selected in the notebook's kernel picker, then restart the kernel.
  • In a plain .py file run from the terminal, there's no notebook to draw into. Use the browser renderer, or run the code in the interactive window.

Show Plotly Charts from a Python Script

Outside notebooks, browser serves the chart to a new tab from a temporary local server.

fig.show(renderer="browser")

Two things surprise people:

  • The server answers once. Refreshing the tab later shows a connection error. Save a file if you want to keep the chart.
  • On a remote machine, container or CI job there may be no browser. Plotly can then end up with an empty default renderer, in which case fig.show() does nothing and raises no error. Write a file there instead.

Write HTML or PNG When Nothing Else Works

These don't depend on any renderer. PNG export with Kaleido 1.x also needs Chrome or Chromium installed; the plotly_get_chrome command downloads a copy if you don't have one.

fig.write_html("chart.html", include_plotlyjs="cdn")   # about 8 KB, needs internet to open
fig.write_html("chart_offline.html")                   # about 4.9 MB, works offline
fig.write_image("chart.png", scale=2)                  # needs: pip install kaleido

See saving figures as standalone HTML and static export with Kaleido.

Set the Default Renderer Permanently

Set it at the top of a script or notebook:

pio.renderers.default = "notebook_connected"

Or use the PLOTLY_RENDERER environment variable, which keeps your code the same across machines:

PLOTLY_RENDERER=browser python report.py

Join names with + to use several at once. "notebook_connected+plotly_mimetype" helps when a notebook is viewed both in Jupyter and as exported HTML.

FigureWidget: Please Install anywidget

go.FigureWidget, used for figures that update from Python callbacks, needs one more package in Plotly 6:

ImportError: Please install anywidget to use the FigureWidget class

Install it with pip install anywidget and restart the kernel. Regular figures don't need it.

Dash and Streamlit Don't Use fig.show()

In a Streamlit app, pass the figure to st.plotly_chart(fig). In Dash, put it in dcc.Graph(figure=fig). Calling fig.show() in either opens a separate tab on the machine running the server, if it does anything.

Having the same trouble with Matplotlib? See why plt.show() isn't showing a figure.

Similar Topics