plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
MIT License
379 stars 39 forks source link

Export to image on Ubuntu under Windows works only the first time #38

Closed cesgarma closed 4 months ago

cesgarma commented 4 years ago

I am using Ubuntu running on Windows 10 using WSL1 (https://ubuntu.com/tutorials/ubuntu-on-windows#1-overview).

The first time I run kaleido write_image function to export a PNG figure it works fine.

The second and subsequent times write_image function hangs. When I interrupt with the keyboard I get the following on the terminal: I have left it run overnight and didn't finish so it definitely hangs.


^CTraceback (most recent call last): File "main.py", line 43, in barChart.graphBarChart(cfg.emotionalGraphFilename, cfg.outputImagesFolder, xAxisLabels, yAxisValues) File "/home/soltuin/devsource/doc-to-pdf/doc-to-pdf/barChart.py", line 81, in graphBarChart fig.write_image(fileName, width=barWidth, height=barHeight, engine="kaleido", validate=False) File "/home/soltuin/pythonenvironments/neocemod/lib/python3.8/site-packages/plotly/basedatatypes.py", line 3251, in write_image return pio.write_image(self, *args, **kwargs) File "/home/soltuin/pythonenvironments/neocemod/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 244, in write_image img_data = to_image( File "/home/soltuin/pythonenvironments/neocemod/lib/python3.8/site-packages/plotly/io/_kaleido.py", line 130, in to_image img_bytes = scope.transform( File "/home/soltuin/pythonenvironments/neocemod/lib/python3.8/site-packages/kaleido/scopes/plotly.py", line 102, in transform response = self._perform_transform( File "/home/soltuin/pythonenvironments/neocemod/lib/python3.8/site-packages/kaleido/scopes/base.py", line 218, in _perform_transform response = self._proc.stdout.readline()


I looked at the kaleido/scopes/base.py line 218 and it seems to be waiting for a response from kaleido process? (I don't know kaleido internals)

Is there anyway I can debug this issue? add verbose of some sort?

cesgarma commented 4 years ago

Adding data to the issue.

Running $ps just noticed that there are many kaleido processes running in the background.

PID TTY TIME CMD 287 pts/0 00:00:01 bash 537 pts/0 00:00:00 kaleido 538 pts/0 00:00:00 kaleido 573 pts/0 00:00:01 kaleido 7601 pts/0 00:00:00 kaleido 7602 pts/0 00:00:00 kaleido 7628 pts/0 00:00:01 kaleido 10061 pts/0 00:00:00 kaleido 10062 pts/0 00:00:00 kaleido 10076 pts/0 00:00:00 kaleido 10170 pts/0 00:00:00 kaleido 10171 pts/0 00:00:00 kaleido 10184 pts/0 00:00:00 kaleido 10473 pts/0 00:00:00 kaleido 10474 pts/0 00:00:00 kaleido 10487 pts/0 00:00:00 kaleido 10545 pts/0 00:00:00 kaleido 10546 pts/0 00:00:00 kaleido 10559 pts/0 00:00:00 kaleido 10565 pts/0 00:00:08 kaleido 10684 pts/0 00:00:00 kaleido 10685 pts/0 00:00:00 kaleido 10698 pts/0 00:00:00 kaleido 10699 pts/0 00:00:00 kaleido 10810 pts/0 00:00:00 kaleido 10811 pts/0 00:00:00 kaleido 10824 pts/0 00:00:00 kaleido 10825 pts/0 00:00:05 kaleido 10981 pts/0 00:00:00 kaleido 10982 pts/0 00:00:00 kaleido 10996 pts/0 00:00:00 kaleido 10997 pts/0 00:00:00 kaleido 11149 pts/0 00:00:00 kaleido 11150 pts/0 00:00:00 kaleido 11176 pts/0 00:00:01 kaleido 11294 pts/0 00:00:00 kaleido 11295 pts/0 00:00:00 kaleido 11308 pts/0 00:00:00 kaleido 11430 pts/0 00:00:00 kaleido 11431 pts/0 00:00:00 kaleido 11444 pts/0 00:00:00 kaleido 11566 pts/0 00:00:00 kaleido 11567 pts/0 00:00:00 kaleido 11580 pts/0 00:00:00 kaleido 11701 pts/0 00:00:00 kaleido 11702 pts/0 00:00:00 kaleido 11715 pts/0 00:00:00 kaleido 11991 pts/0 00:00:00 kaleido 11992 pts/0 00:00:00 kaleido 12005 pts/0 00:00:00 kaleido 12126 pts/0 00:00:00 kaleido 12127 pts/0 00:00:00 kaleido 12140 pts/0 00:00:00 kaleido 12209 pts/0 00:00:00 kaleido 12210 pts/0 00:00:00 kaleido 12223 pts/0 00:00:00 kaleido 12274 pts/0 00:00:00 kaleido 12275 pts/0 00:00:00 kaleido 12288 pts/0 00:00:00 kaleido 12289 pts/0 00:00:00 kaleido 12336 pts/0 00:00:00 kaleido 12337 pts/0 00:00:00 kaleido 12351 pts/0 00:00:00 kaleido 12408 pts/0 00:00:00 kaleido 12409 pts/0 00:00:00 kaleido 12422 pts/0 00:00:00 kaleido 12496 pts/0 00:00:00 kaleido 12497 pts/0 00:00:00 kaleido 12513 pts/0 00:00:00 kaleido 12552 pts/0 00:00:00 kaleido 12553 pts/0 00:00:00 kaleido 12567 pts/0 00:00:00 kaleido 12600 pts/0 00:00:00 kaleido 12601 pts/0 00:00:00 kaleido 12615 pts/0 00:00:00 kaleido 12660 pts/0 00:00:00 kaleido 12661 pts/0 00:00:00 kaleido 12675 pts/0 00:00:00 kaleido 12676 pts/0 00:00:05 kaleido 12721 pts/0 00:00:00 kaleido 12722 pts/0 00:00:00 kaleido 12739 pts/0 00:00:00 kaleido 12830 pts/0 00:00:00 kaleido 12831 pts/0 00:00:00 kaleido 12843 pts/0 00:00:00 kaleido 12900 pts/0 00:00:00 kaleido 12901 pts/0 00:00:00 kaleido 12914 pts/0 00:00:00 kaleido 12966 pts/0 00:00:00 kaleido 12967 pts/0 00:00:00 kaleido 12981 pts/0 00:00:00 kaleido 12983 pts/0 00:00:05 kaleido 13147 pts/0 00:00:00 kaleido 13148 pts/0 00:00:00 kaleido 13162 pts/0 00:00:00 kaleido 13189 pts/0 00:00:00 ps

jonmmease commented 4 years ago

Hi @cesgarma, thanks for the report.

The next thing you could try would be to call the kaleido native executable from the command line. There are some instructions for that in https://github.com/plotly/Kaleido/issues/26#issuecomment-664948907. These were written for Windows, but the approach is the same for Linux.

Since you're export is working the first time, I expect everything will work up until the first time you enter {"data":{"layout":{}}}, so do this part multiple times. It will probably hang the second time, but hopefully chromium will output some error info. Please copy all of the terminal output that you see.

All that said, it looks like folks have had trouble with using Chromium-based projects under WSL 1. See https://github.com/microsoft/WSL/issues/648 and https://github.com/microsoft/WSL/issues/2760. So it might not be possible to get this working reliably. I expect things will work better on WSL 2 since this is based on a true Linux VM instead of a Linux-to-windows translation layer.

gvwilson commented 4 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