Skip to content

write_image does not work Plotly 6.3+, Windows 10 (seemingly regardless of kaleido version) #402

@iiwolf

Description

@iiwolf

Hello, as discussed in this issue, for the longest time you had to use pip install kaleido==0.1.0.post1 specifically to be able to write an image otherwise it'd hang forever. In 6.3, that seems to break for a different reason:

Traceback (most recent call last):
  File "C:\Users\User\projects\ftdb\test.py", line 4, in <module>
    fig.write_image("figure.png")
  File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\plotly\basedatatypes.py", line 3895, in write_image
    return pio.write_image(self, *args, **kwargs)
  File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\plotly\io\_kaleido.py", line 510, in write_image
    img_data = to_image(
  File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\plotly\io\_kaleido.py", line 398, in to_image
    img_bytes = scope.transform(
  File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\kaleido\scopes\plotly.py", line 111, in transform
    raise ValueError(
ValueError: Transform failed with error code 1: Failed to serialize document: Uncaught

With upgrading to 1.0.0 I get the following error:

ERROR   Thread(Thread-1 (run)) asyncio:base_events.py:default_exception_handler()- Exception in callback Broker.run_read_loop.<locals>.check_read_loop_error(<Task cancell...async.py:129>>) at C:\Users\User\Anaconda3\envs\test\lib\site-packages\choreographer\_brokers\_async.py:112
handle: <Handle Broker.run_read_loop.<locals>.check_read_loop_error(<Task cancell...async.py:129>>) at C:\Users\User\Anaconda3\envs\test\lib\site-packages\choreographer\_brokers\_async.py:112>
 Traceback (most recent call last):
   File "C:\Users\User\Anaconda3\envs\test\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
   File "C:\Users\User\Anaconda3\envs\test\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
   File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\kaleido\__init__.py", line 54, in calc_fig
    async with Kaleido(**kopts) as k:
   File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\choreographer\browser_async.py", line 167, in __aenter__  
    await self.open()
   File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\choreographer\browser_async.py", line 151, in open        
    await self.populate_targets()
   File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\kaleido\kaleido.py", line 181, in populate_targets        
    raise RuntimeError("Did you set 0 or less tabs?")
 RuntimeError: Did you set 0 or less tabs?

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\choreographer\_brokers\_async.py", line 132, in read_loop 
    responses = await loop.run_in_executor(
 asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "C:\Users\User\Anaconda3\envs\test\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
   File "C:\Users\User\Anaconda3\envs\test\lib\site-packages\choreographer\_brokers\_async.py", line 113, in check_read_loop_error
    e = result.exception()
 asyncio.exceptions.CancelledError

And you can't even exit the terminal, you have to kill it from somewhere else.

Both of these on the MRE shown below, fresh conda environment with python 3.10 and just Plotly 6.3 and kaleido installed

import plotly.graph_objects as go
fig = go.Figure(data=[go.Scatter(y=[1, 3, 2])])
fig.write_image("figure.png")
# Also tried
# from kaleido import write_fig_sync
# pio.write_image(fig, "output.png")
# write_fig_sync(fig, path="figure.png")

Full conda environment:

bzip2                     1.0.8                h2466b09_7    conda-forge
ca-certificates           2025.8.3             h4c7d964_0    conda-forge
choreographer             1.0.10                   pypi_0    pypi
kaleido                   1.0.0                    pypi_0    pypi
libexpat                  2.7.1                hac47afa_0    conda-forge
libffi                    3.4.6                h537db12_1    conda-forge
liblzma                   5.8.1                h2466b09_2    conda-forge
libsqlite                 3.50.4               hf5d6505_0    conda-forge
libzlib                   1.3.1                h2466b09_2    conda-forge
logistro                  1.1.0                    pypi_0    pypi
narwhals                  2.3.0                    pypi_0    pypi
openssl                   3.5.2                h725018a_0    conda-forge
orjson                    3.11.3                   pypi_0    pypi
packaging                 25.0                     pypi_0    pypi
pip                       25.2               pyh8b19718_0    conda-forge
plotly                    6.3.0                    pypi_0    pypi
python                    3.10.18         h8c5b53a_0_cpython    conda-forge
setuptools                80.9.0             pyhff2d567_0    conda-forge
simplejson                3.20.1                   pypi_0    pypi
tk                        8.6.13               h2c6b04d_2    conda-forge
tzdata                    2025b                h78e105d_0    conda-forge
ucrt                      10.0.26100.0         h57928b3_0    conda-forge
vc                        14.3                h2df5915_10
vc14_runtime              14.44.35208         h818238b_31    conda-forge
vcomp14                   14.44.35208         h818238b_31    conda-forge
wheel                     0.45.1             pyhd8ed1ab_1    conda-forge

Let me know if I can provide any other context or if there's a known workaround.

Thank you!

Isaac

Metadata

Metadata

Assignees

Labels

P1needs immediate attentionbugsomething broken

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions