I have never used plotly before, and I have been trying to export a sample image code to png. I have installed plotly and kaleido and ran the code on python 3, but nothing happens.
#Here is the code:
import plotly.express as px
import numpy as np
# RGB Data as numpy array
img_rgb = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255]],], dtype=np.uint8)
fig = px.imshow(img_rgb)
fig.show()
fig.write_image("fig.png")
According to the plotly documentation, that should do the trick, but I can't get a png image. It shows no errors, no warnings... it's like python is stuck in an infinite loop. I can't even stop the terminal from running.
I'm using python 3.9.6 64-bit
I have tried plotly latest version (5.3.1) and an older version (4.14.3), but I've got the same problem.
python -m pip install plotly
kaleido is the latest version (0.2.1), but I have tried version (0.2.0) too.
python -m pip install -U kaleido
What could I be doing wrong?
UPDATE: I have tried the same process in another computer, and it worked ok. Any ideas why the first computer won't run the code?
I run Windows 10 Enterprise and this worked for me:
Downgrade Kaleido to version 0.1.0post1 (which is the latest in 0.1.*):
pip install --upgrade "kaleido==0.1.*"
Then image creation started working. Also see:
https://stackoverflow.com/a/71621135/660259
Funny thing? kaleido v0.2.1 works fine on windows server 2019, but not on my work-computer Windows 10 Enterprise
I had the same issue. tried everything. nothing worked! then finally installed orca. and... It worked!!! I would suggest installing Orca for static image write when using Plotly, if nothing works.
fig.write_image('fig1.png', engine='orca')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With