Closed adammclaurin closed 4 months ago
Hi @adammclaurin, Kaleido shold be compatible with that configuration. Does your system have SELinux running? If so, https://github.com/plotly/Kaleido/issues/37 might be helpful.
If not, try the instructions in https://github.com/plotly/Kaleido/issues/36#issuecomment-756676527 to see if we can get a little more logging info.
Thanks for the feedback @jonmmease . I confirmed that SELinux is not running.
Here's a screenshot of the backtrace that gets printed when I stop the Jupyter kernel while write_image() is hung:
And here's a screenshot of the output of the debugging command you suggested:
Any suggestions?
Huh, that logging info is all normal.
Previously, some folks had an issue with Kaleido hanging while working behind a proxy that hung kaleido's attempt to pull MathJax from a CDN. So you can try two things from (https://github.com/plotly/Kaleido/issues/36#issuecomment-766704225)
Just FYI, kaleido 0.2.1 does bundle MathJax, but plotly.py still overrides the local MathJax path to point to the CDN location. In plotly.py 5, plotly.py will let kaleido use its local offline MathJax, so this won't be an issue any more.
Thanks @jonmmease, that was exactly the issue. I'm working in a private JupyterHub environment that doesn't have direct access to the internet. Disabling MathJax as you suggested fixed the issue.
Do you have an estimate of when plotly.py 5 will be generally available?
Without committing strongly to any timeline, my hope is that plotly
v5 will be available in late April/early May.
It seems that I ran into the same error, however, the proposed solution does not work. I tried the code snipped below and it remains hanging indefinitely. My setup is a Python 3.8.5 venv on Ubuntu (through WSL). Kaleido is version 0.2.1 and Plotly 4.14.3. Downgrading to kaleido 0.1.0 works.
import plotly.io as pio
pio.kaleido.scope.mathjax = None
import plotly.graph_objects as go
import json
# Figure
fig = go.Figure(
data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])],
layout=go.Layout(
title=go.layout.Title(text="A Figure Specified By A Graph Object")
)
)
# Display original figure
# fig.show() # Works
fig.write_image("original_figure.png", format="png", engine="kaleido") # Works
In Windows on Python 3.8 the code snippet does work. Also without setting mathjax to None.
The temporary solution I posted above did not work on another setup. Now I am wondering if the problem is maybe not the same. On the bottom of this post the traceback after I run a KeyboardInterrupt (when it keeps hanging). It seems to be hanging in response = self._proc.stdout.readline()
, does this mean that is the same issue?
Note: I installed plotly from jonmmease's branch 'kaleido_v5_updates'. Besides that, kaleido 0.2.1 is now installed. The reference to MathJax.js with this combo of plotly and kaleido is correct:
>>> import plotly.io as pio
>>> scope_pio = pio.kaleido.scope
>>> scope_pio.mathjax
'file:///ScratchProject/TestPlotlyUpdateInstallV1/uenv/lib/python3.8/site-packages/kaleido/executable/etc/mathjax/MathJax.js'
(uenv) chris@Notebook:/ScratchProject/TestPlotlyUpdateInstallV1$ python export_figure.py
^CTraceback (most recent call last):
File "export_figure.py", line 18, in <module>
fig.write_image(file=export_path, width=1280, height=720, scale=1.0, engine="kaleido", format="png")
File "/ScratchProject/TestPlotlyUpdateInstallV1/uenv/lib/python3.8/site-packages/plotly/basedatatypes.py", line 3806, in write_image
return pio.write_image(self, *args, **kwargs)
File "/ScratchProject/TestPlotlyUpdateInstallV1/uenv/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 258, in write_image
img_data = to_image(
File "/ScratchProject/TestPlotlyUpdateInstallV1/uenv/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 144, in to_image
img_bytes = scope.transform(
File "/ScratchProject/TestPlotlyUpdateInstallV1/uenv/lib/python3.8/site-packages/kaleido/scopes/plotly.py", line 103, in transform
response = self._perform_transform(
File "/ScratchProject/TestPlotlyUpdateInstallV1/uenv/lib/python3.8/site-packages/kaleido/scopes/base.py", line 297, in _perform_transform
response = self._proc.stdout.readline()
KeyboardInterrupt
Hi @chrispijo,
Would you mind opening a new issue and copying this info over there? My guess is that this is related to running on WSL, rather than the MathJax issue discussed in this thread.
In that new issue, could you please include the output of running the following command after using Ctrl+C to interrupt the write process:
import plotly.io as pio
scope = pio.kaleido.scope
print(scope._std_error.getvalue().decode())
Thanks!
Happy to do so.
It seems that I ran into the same error, however, the proposed solution does not work. I tried the code snipped below and it remains hanging indefinitely. My setup is a Python 3.8.5 venv on Ubuntu (through WSL). Kaleido is version 0.2.1 and Plotly 4.14.3. Downgrading to kaleido 0.1.0 works.
import plotly.io as pio pio.kaleido.scope.mathjax = None import plotly.graph_objects as go import json # Figure fig = go.Figure( data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])], layout=go.Layout( title=go.layout.Title(text="A Figure Specified By A Graph Object") ) ) # Display original figure # fig.show() # Works fig.write_image("original_figure.png", format="png", engine="kaleido") # Works
In Windows on Python 3.8 the code snippet does work. Also without setting mathjax to None.
I have the same questions
Downgrading kaleido also worked for me, although 0.1.0 caused a different error, so I had to use 0.0.3
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
I'm using kaleido 0.2.1 with plotly 4.14.3 on Python 3.8.1 and RHEL Linux 7.9. I'm trying to run the below example notebook but the write_image() calls never return: https://plotly.com/python/static-image-export/
I tried multiple image formats and nothing seems to work. Is this a known issue?
Thanks!