Static image export hangs using kaleido

I’m following this tutorial and trying to export a plot to a static image but nothing happens, the script hangs.

I believe the problem is on this line that never produces a value.

The contents of proc_args (computed here) are:

C:\Users\<username>\PycharmProjects\imgexport\venv\lib\site-packages\kaleido\executable\kaleido.cmd
plotly
--plotlyjs='C:\\Users\\<username>\\PycharmProjects\\imgexport\\venv\\lib\\site-packages\\plotly\\package_data\\plotly.min.js'
--mathjax='file:///C:/Users/<username>/PycharmProjects/imgexport/venv/lib/site-packages/kaleido/executable/etc/mathjax/MathJax.js'
--disable-gpu
--allow-file-access-from-files
--disable-breakpad
--disable-dev-shm-usage
--no-sandbox

My setup:

Windows 10

kaleido 0.2.1
numpy 1.22.2
pip 21.1.2
plotly 5.6.0
setuptools 57.0.0
six 1.16.0
tenacity 8.0.1
wheel 0.36.2


Adding pio.kaleido.scope.mathjax = None doesn’t help.

HI @lambdakappatheta
Good question. Do you have the code that you used to create a static image? If we tried to replicate your error on our computer, it might be easier to solve.

Hi! Thank you for your response. This is the code I used:

import numpy as np
import plotly.graph_objects as go


if __name__ == '__main__':
    np.random.seed(1)

    N = 100
    x = np.random.rand(N)
    y = np.random.rand(N)
    colors = np.random.rand(N)
    sz = np.random.rand(N) * 30

    fig = go.Figure()
    fig.add_trace(go.Scatter(
            x=x,
            y=y,
            mode="markers",
            marker=go.scatter.Marker(
                    size=sz,
                    color=colors,
                    opacity=0.6,
                    colorscale="Viridis"
            )
    )
    )

    fig.write_image("fig1.png")

@lambdakappatheta
Have you seen this issue? are you using Windows?

Downloading and installing 0.1.0.post1 should work.
I downloaded this wheel:

kaleido-0.1.0.post1-py2.py3-none-win_amd64.whl

And then installed:
pip install kaleido-0.1.0.post1-py2.py3-none-win_amd64.whl

2 Likes

0.1.0.post1 works!
Yes, using Windows 10.
Thank you!

Was just checking out the same tutorial and encountered the same problem.

I’m not familiar with .whl files and I prefer to use conda instead of pip. Is there a conda install version of this β€œkaleido-0.1.0.post1-py2.py3-none-win_amd64.whl” ?

You can try conda install python-kaleido==0.1.0. It works for me on win 11.

1 Like

My script hung at fig.write_image(dir_pic) using Kaleido 0.2.1. Installing Kaleido 0.1.0 fixed the issue. Thanks for the tip