"write_image" for exporting fig takes forever and does not create a static image in jupyter notebook

Hello there,

I’m recently starting to work with plotly libraries. I’m able to generate my treemap and see it by ‘show.fig’. Unfortunately, though, all the methods that I’ve tested to export the treemap so far are not working (e.g., kaleido). I’m making all the scripts in jupyter, but I also already tried it with python in the terminal. Basically, when I give the command “write_table” the jupyter notebook will be running “forever”, but not exporting the treemap to a png image file. It might be a silly thing (that I’m missing), but it would be nice if you could help me!

Bellow goes my code:

import plotly.express as px
import plotly.graph_objects as go
import numpy as np
import pandas as pd

from kaleido.scopes.plotly import PlotlyScope
from dash import Dash, dcc, html, Input, Output
from base64 import b64encode

exemple_1 = pd.read_csv('exemple_1.csv')
fig = px.treemap(exemple_1, path=[px.Constant("clusters"),'Cluster', 'parameter_1'], values='parameter_2',
                  color='parameter_3', hover_data=['parameter_4'],
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
#from this part on my jupyter notebook will be running "forever", but not exporting the respective png image

The version of kaleido you are using is unknown, but previous answers https://community.plotly.com/t/static-image-export-hangs-using-kaleido/61519 have suggested solutions for similar events. Please refer to them.

If you’re just trying to export the fig why don’t you just do it as an HTML file? Exporting as an HTML it will keep the interactivity functionality intact and then if a user requires a PNG from there they can use the plotly toolbar to export a PNG.

To export it as a HTML use


I do see you’re initially talking about PNG exporting here. I do have an idea I can try out if you really are wanting a PNG. I’m currently replying from my phone so I can’t test right now.

Let me know if a the HTML file works or if you do really want a PNG. I’ll wait to hear back then will try out the idea of you do want it.