Fix Plotly write_image Errors: Kaleido Not Installed or Chrome Not Found

fig.write_image() fails when Kaleido is missing, the wrong version, or Chrome can't be found. Match your error text to the fix: pip install -U kaleido, plotly_get_chrome, or pin the version that fits your Plotly.

fig.write_image() and fig.to_image() need the Kaleido package, and since Kaleido 1.0 they also need Google Chrome. If your export fails with Image export requires the Kaleido package, v1.0.0 or greater, run pip install -U kaleido. If it says Kaleido requires Google Chrome to be installed, run plotly_get_chrome. The code and error messages here come from Plotly 7.2.0 and Kaleido 1.5.2, with the older versions checked separately.

Quick Example

For Plotly 6.1 and newer, install both pieces once, then export:

pip install -U kaleido
plotly_get_chrome -y
import numpy as np
import pandas as pd
import plotly.express as px

rng = np.random.default_rng(7)
drinks = ["Flat white", "Cortado", "Cold brew", "Matcha latte", "Espresso", "Chai"]
df = pd.DataFrame({"drink": drinks, "cups": rng.integers(40, 220, len(drinks))})

fig = px.bar(
    df.sort_values("cups"), x="cups", y="drink", orientation="h",
    title="Cups sold on Saturday", color_discrete_sequence=["#7a4e2d"],
)
fig.write_image("cups.png", width=800, height=450, scale=2)

Horizontal bar chart of cups sold on Saturday for six coffee drinks, exported to a PNG with fig.write_image

If that runs silently and creates cups.png, you're done. If it raises an error, find your message below.

Which write_image error do you have?

Error text Cause Fix
RuntimeError: Image export requires the Kaleido package, v1.0.0 or greater Kaleido isn't installed, or only the old 0.2.1 is pip install -U kaleido
RuntimeError: Kaleido requires Google Chrome to be installed Kaleido is fine, but it can't find a Chrome plotly_get_chrome, or set BROWSER_PATH
ValueError: Image export using the "kaleido" engine requires the kaleido package Plotly 6.0 or older with Kaleido 1.x Upgrade Plotly, or pip install kaleido==0.2.1
ValueError: EPS export is no longer supported by Kaleido You asked for .eps Export .svg or .pdf instead

RuntimeError: Image export requires the Kaleido package, v1.0.0 or greater

Plotly 7 raises this whenever it can't import Kaleido 1.0 or newer. That covers two situations: Kaleido isn't installed at all, or an old Kaleido 0.2.1 is installed. I got the identical message from both on Plotly 7.2.0.

pip install -U kaleido

Install it into the same environment that runs your code. In Jupyter, use %pip install -U kaleido so it lands in the kernel's environment, then restart the kernel. If you use uv, run uv add kaleido.

Check what the interpreter actually sees:

import importlib.metadata as md

print("plotly ", md.version("plotly"))
print("kaleido", md.version("kaleido"))

You need Kaleido 1.0.0 or newer on Plotly 7. If md.version("kaleido") raises PackageNotFoundError, it isn't installed in this environment.

RuntimeError: Kaleido requires Google Chrome to be installed

Kaleido 0.2.1 shipped its own copy of Chromium. Kaleido 1.x doesn't, so it looks for a Chrome or Chromium install on your machine. Plotly raises this error when it finds none. You have three options:

  • Let Plotly download one. Run plotly_get_chrome in a terminal (add -y to skip the confirmation). It installs Chrome for Testing into a folder Kaleido checks automatically. Inside a notebook, use !plotly_get_chrome -y, or call plotly.io.get_chrome() from Python.
  • Install Chrome normally from Google, or Chromium from your package manager.
  • Point Kaleido at an existing browser with the BROWSER_PATH environment variable.
import plotly.io as pio

pio.get_chrome()   # same as running plotly_get_chrome; downloads Chrome for Testing

plotly_get_chrome --path /some/folder installs to a folder you choose. If Kaleido doesn't find a browser you installed to a custom folder, set BROWSER_PATH to the executable path the command prints at the end:

BROWSER_PATH="/some/folder/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing" python make_charts.py

On a server or in a Docker image, run plotly_get_chrome -y once while building so exports don't download anything at runtime.

ValueError on Plotly 5 and 6.0: requires the kaleido package

On Plotly 5.x and 6.0, a Kaleido 1.x install produces a misleading message even though Kaleido is installed:

ValueError:
Image export using the "kaleido" engine requires the kaleido package,
which can be installed using pip:
    $ pip install -U kaleido

Those Plotly releases only know how to talk to Kaleido 0.2.1, so following the advice in the message (pip install -U kaleido) installs the very version that triggers it. Pick one:

  • Upgrade Plotly to 6.1 or newer: pip install -U plotly kaleido, then install Chrome as above.
  • Pin the old Kaleido to keep your Plotly: pip install kaleido==0.2.1. It bundles its own Chromium, so no Chrome install is needed.

Which Kaleido version goes with which Plotly?

Plotly Kaleido 0.2.1 Kaleido 1.x
5.x to 6.0 Works, no Chrome needed Fails with the ValueError above
6.1 to 6.x Works, with a deprecation warning Works, needs Chrome
7.x RuntimeError, not supported Works, needs Chrome

I ran 5.24.1, 6.0.0, 6.1.0, 6.5.0 and 7.2.0 against both Kaleido versions to fill this in. On 6.5.0 with Kaleido 0.2.1, the warning reads "Support for Kaleido versions less than 1.0.0 is deprecated", and Plotly 7 removed that support.

For new projects, use Plotly 6.1 or newer with Kaleido 1.x. Installing plotly[kaleido] pulls in a compatible Kaleido (it requires kaleido>=1.3.0).

ValueError: EPS export is no longer supported

Kaleido 0.2.1 could write .eps files, and Kaleido 1.x can't. Plotly raises ValueError: EPS export is no longer supported by Kaleido. Please use SVG or PDF instead. Change the extension to .svg or .pdf; both are vector formats, so they scale for print the same way.

Check the export settings once it works

When the install is fixed, width, height and scale control the output size. The PNG's pixel size is width * scale by height * scale, which you can confirm from the bytes fig.to_image() returns:

import struct

img = fig.to_image(format="png", width=800, height=450, scale=2)
width_px, height_px = struct.unpack(">II", img[16:24])
print(width_px, height_px)   # 1600 900

The Quick Example image is 1600 by 900 pixels for that reason. For a bigger export guide covering formats, bytes and Plotly Express, see exporting static images with Kaleido.

Practical Tips

  • Test the install with a one-line script, python -c "import plotly.graph_objects as go; go.Figure().write_image('t.png')", before debugging your real chart. An empty figure exercises Kaleido and Chrome without any of your data.
  • Pin plotly and kaleido together in requirements.txt or pyproject.toml. A Plotly upgrade past a Kaleido boundary is the usual reason exports that worked last month fail today.
  • Don't keep exporting inside a loop you don't need. Each write_image() call starts a browser, so build several figures and write them in one pass where you can.
  • If you only need a file to share, fig.write_html() works with no Kaleido or Chrome at all. See saving interactive Plotly figures as standalone HTML.

Similar Topics