plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
Other
363 stars 37 forks source link

Program freezes when trying to save plotly.express.box to a PNG via write_image #195

Open ayhteo opened 2 years ago

ayhteo commented 2 years ago

I get this issue where the program freezes when trying to save a plotly.express.box via write_image into a .PNG file.

from PIL import Image, ImageFont, ImageDraw
import pandas as pd
import numpy as np
import plotly.express as px
from plotly.io import write_image
confluency_df = pd.DataFrame([[f"Directory 0", np.random.uniform()*100] for i in range(10)], columns=["directory", "confluency (%)"])
plotly_fig = px.box(
        confluency_df,
        x="directory",
        y="confluency (%)",
        boxmode="overlay",
        points="all",
    )
plotly_fig
plotly_fig.write_image("src/static/results/confluency_graph.png")

The strange thing is it seems to freeze the whole program without throwing an error. All steps work fine up to the last line above.

I am using the following: plotly==5.8.0 kaleido==0.2.1

ayhteo commented 2 years ago

I tried following advice from https://github.com/plotly/Kaleido/issues/98 using the orca engine, using plotly==5.3.1. However, it still hangs.

Just to note, all these problems happen on my Windows 10 and there is no issues on my MacOS with kaleido.

AnupamSaraph commented 2 years ago

I have the same issue. While the code below would earlier produce png, svg, or html based on the extension, it is going into an endless execution of the cell and producing no output even after three hours.

import plotly.graph_objects as go
import numpy as np
from pathlib import Path

file_name = Path.cwd().joinpath("images")
if not f.is_dir(): f.mkdir()
file_name = file_name.joinpath("fig1.png")

fig = go.Figure(go.Scatter(x=np.linspace(1,10,100), y=np.sin(np.linspace(-np.pi,np.pi, 100))))
fig.show()
fig.write_image(file_name, engine='auto')

I am using plotly 5.8.0 and kaleido 0.2.1 I was unsuccessful to get it to work in all plotly versions till 5.5.0 where it was previously working

https://user-images.githubusercontent.com/1920565/169955341-498b2543-0702-4dd1-a531-09ab0af4dcc8.mp4

lorenzo-w commented 1 year ago

Facing the same issue with plotly 5.12.0 and kaleido 0.2.1 on Windows 11. Anybody working on this?

j-adamczyk commented 1 year ago

Same issue on Windows 10 in Jupyter Notebook, plotly 5.13.0 and kaleido 0.2.1

Facenomore23 commented 1 year ago

Downgrading to kaleido 0.1.0post1 fixted the issue : pip install --upgrade kaleido=="0.1.0.post1"

oaksharks commented 1 year ago

The issue still exists with plotly 5.14.1 and orca=1.8 on Windows 11. image

xsadusx commented 7 months ago

I am facing the same problem the code I have generating word report based on csv data, creates sankey.png and attach it to word doc. It work fine until I replaced my CPU. My previous CPU was Ryzen5 1500pro and worked fine. New Ryzen 9 5900 hangs (or rather this small piece of code _(image_path = "sankey_chart_full.png" fig.write_image(imagepath) ) during png saving (other formats not working either). I can export sankey as html only. It is definitely follows CPU, any idea what it is, CPU microcode?

Edit: The problem is related to OS. I uses Win10 which was installed on my old R5 1500 and replacing to new CPU is causing unknown problem by now to export data as png or other format static image format. The same new CPU + the same script, but different OS (Ubuntu) no problem found. It looks like I need to refresh my Win installation.

rabyj commented 3 months ago

I had a similar problem on Ubuntu 20.04.6, for both png and svg. Versions were

python==3.8.10
kaleido==0.2.1
plotly==5.11.0

Updated plotly to 5.22.0 and it then worked.

I work on a notebook, sometimes it still freezes, and restarting the notebook fixes it. Really strange bug.

gvwilson commented 2 months ago

Thanks for your interest in Kaleido. We are currently working on an overhaul that might address your issue - we hope to have news in a few weeks and will post an update then. Thanks - @gvwilson

ccscroggin commented 3 days ago

Switching to 5.22.0 plotly and 0.1.0.post1 kaleido fixed for me