Skip to content

Issues with parenthesis in kaleido installation path #209

Closed

Description

@mmarras

Hello,

I am using plotly's fig.write_image() (plotly 5.24.1) [fig.write_html() works fine]

I am on a work machine, windows 10 enterprise and am boxed in and can only install to my user folder, so that's where I have miniconda installed. However my user folder has a parenthesis in it which likely clashes with some internal shell/batch scripting. Changing the location of the output file to "c:\temp" is still promting the same error.

'c:\Users\MArras' is not recognized as an internal or external command,
operable program or batch file.

Note here that my user folder is: c:\Users\MArras(NL)\ and not c:\Users\MArras

here is the full error dump:

---------------------------------------------------------------------------
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File c:\Users\MArras(NL)\datamore\misc\intensity_pressure\intensity_pressure.py:91
     77 fig = plot_results_with_buttons(
     78     data_dict,
     79     image=crop_image_by_vector(roi_color_full_img, mask),
   (...)
     86     calib_min="5 bar",
     87 )
     88 # Show the figure
     89 # fig.show()
     90 # fig.write_html(pdf.parent / f"{pdf.stem}.html")
---> 91 fig.write_image(Path(r"C:\temp") / f"{pdf.stem}.png")

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\plotly\basedatatypes.py:3835, in BaseFigure.write_image(self, *args, **kwargs)
   3775 """
   3776 Convert a figure to a static image and write it to a file or writeable
   3777 object
   (...)
   3831 None
   3832 """
   3833 import plotly.io as pio
-> 3835 return pio.write_image(self, *args, **kwargs)

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\plotly\io\_kaleido.py:266, in write_image(fig, file, format, scale, width, height, validate, engine)
    250             raise ValueError(
    251                 """
    252 Cannot infer image type from output path '{file}'.
   (...)
    260                 )
    261             )
    263     # Request image
    264     # -------------
    265     # Do this first so we don't create a file if image conversion fails
--> 266     img_data = to_image(
    267         fig,
    268         format=format,
    269         scale=scale,
    270         width=width,
    271         height=height,
    272         validate=validate,
    273         engine=engine,
    274     )
    276     # Open file
    277     # ---------
    278     if path is None:
    279         # We previously failed to make sense of `file` as a pathlib object.
    280         # Attempt to write to `file` as an open file descriptor.

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\plotly\io\_kaleido.py:143, in to_image(fig, format, width, height, scale, validate, engine)
    140 # Validate figure
    141 # ---------------
    142 fig_dict = validate_coerce_fig_to_dict(fig, validate)
--> 143 img_bytes = scope.transform(
    144     fig_dict, format=format, width=width, height=height, scale=scale
    145 )
    147 return img_bytes

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\kaleido\scopes\plotly.py:153, in PlotlyScope.transform(self, figure, format, width, height, scale)
    142     raise ValueError(
    143         "Invalid format '{original_format}'.\n"
    144         "    Supported formats: {supported_formats_str}"
   (...)
    148         )
    149     )
    151 # Transform in using _perform_transform rather than superclass so we can access the full
    152 # response dict, including error codes.
--> 153 response = self._perform_transform(
    154     figure, format=format, width=width, height=height, scale=scale
    155 )
    157 # Check for export error, later can customize error messages for plotly Python users
    158 code = response.get("code", 0)

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\kaleido\scopes\base.py:293, in BaseScope._perform_transform(self, data, **kwargs)
    284 """
    285 Transform input data using the current scope, returning dict response with error code
    286 whether successful or not.
   (...)
    290 :return: Dict of response from Kaleido executable, whether successful or not
    291 """
    292 # Ensure that kaleido subprocess is running
--> 293 self._ensure_kaleido()
    295 # Perform export
    296 export_spec = self._json_dumps(dict(kwargs, data=data)).encode('utf-8')

File c:\Users\MArras(NL)\AppData\Local\miniconda3\envs\datamore\lib\site-packages\kaleido\scopes\base.py:198, in BaseScope._ensure_kaleido(self)
    193 if not startup_response_string:
    194     message = (
    195         "Failed to start Kaleido subprocess. Error stream:\n\n" +
    196         self._get_decoded_std_error()
    197     )
--> 198     raise ValueError(message)
    199 else:
    200     startup_response = json.loads(startup_response_string)

ValueError: Failed to start Kaleido subprocess. Error stream:

'c:\Users\MArras' is not recognized as an internal or external command,
operable program or batch file.

Activity

  1. ayjayt commented on Oct 24, 2024

    @ayjayt
    Collaborator

    Hi @mmarras

    Will you do me a favor and re-install kaleido with
    pip install --pre kaleido

    This will install the yet-to-be-release rewrite of kaleido, and this problem may disappear. Fair warning, it is alpha so it may throw a different error.

    Either way I think I can help get this resolved today. Thanks!

  2. mmarras commented on Oct 24, 2024

    @mmarras
    Author

    Different error indeed:

    RuntimeError: Kaleido doesn't support asyncio + the old kaleido API yet.

  3. ayjayt commented on Oct 24, 2024

    @ayjayt
    Collaborator

    That is very useful, thank you, I'll get back to you in a couple hours

  4. added
    bug
    P2
    TNG
    on Oct 24, 2024
  5. ayjayt commented on Oct 24, 2024

    @ayjayt
    Collaborator

    @mmarras for context, plotly had to rewrite kaleido because the original strategy was no longer tenable, and I just had you install the new release.

    it's in internal testing right now-

    I've just fixed the

    RuntimeError: Kaleido doesn't support asyncio + the old kaleido API yet.

    but I can't speak for what might happen afterwards..

    The rewrite requires chrome or chromium installed on the system- the old version bundled it but its huge now and that doesn't work. (let me know if that's a problem)

    You can install the development branch directly with:
    python3 -m pip install git+https://github.com/plotly/kaleido@devtools/main#subdirectory=src/py

    or if you don't mind waiting, I will @ you when a new --pre is pushed to pypi!

    Thank you so much for your patience and help!

  6. mmarras commented on Oct 24, 2024

    @mmarras
    Author

    No more error message, but also no image generation. Keeps being busy indefinitely. Chrome 70 is on the system as a managed installation.

  7. ayjayt commented on Oct 24, 2024

    @ayjayt
    Collaborator

    Hi @mmarras, I really apologize about all this...

    I've submitted another commit to that branch to allow verbose (very) debugging output, and it can be enabled if the image is written as:

    from kaleido.scopes.plotly import PlotlyScope
    scope = PlotlyScope(debug=True)
    with open(str(Path(r"C:\temp") / f"{pdf.stem}.png)"), "wb") as f:
             f.write(scope.transform(fig, format="png"))

    I copied your original post to make that.

    I would need that debugging output to help further, and any additional information about the system.

    Thank you so much,

  8. mmarras commented on Oct 31, 2024

    @mmarras
    Author

    Hi sorry, for getting back to this just now.

    The folders (browser_path, user_data_dir) are correct, accessible and contain data but it stops right there after 2s of processing it just hangs.

    Got running loop, threading
    Calling thread start
    Calling to_image in thread
    DEBUG REPORT:
    BROWSER_PATH: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    USER_DATA_DIR: C:\Users\MARRAS~1\AppData\Local\Temp\tmpz65us1nn
    We are in a selector event loop, use loop_hack
    read_jsons (blocking):
    write_json:
    write_json: {"id": 0, "method": "Target.getTargets"}
    Starting watchdog
    wrote_json.
    {"id":0,"result":{"targetInfos":[]}}

  9. ayjayt commented on Oct 31, 2024

    @ayjayt
    Collaborator

    Hi @mmarras, there are quite a few bugfixes and updates coming out probably EOD today (maybe tomorrow morning), so your issue might get fixed there... also coming with improved debug. I'll ping you when it's ready!

  10. ayjayt commented on Nov 4, 2024

    @ayjayt
    Collaborator

    Hi @mmarras, so there is a new release candidate on pypi for kaleido. (must pass --pre to pip to install it)

    It includes several bug fixes, several hang fixes, and the option for increasing debug output.

    It is currently going through rounds of alpha testing internally, and I'm sure will be even more stable once that is finished.

    I appreciate your patience on these issues!

  11. ayjayt commented on Nov 15, 2024

    @ayjayt
    Collaborator

    New version is now main version- many bogs were squashed since this issue started. I wonder if there is an update?

  12. gvwilson commented on Nov 19, 2024

    @gvwilson
    Contributor

    @mmarras can you please let us know if v1.0.0rc0 fixes your problems?

  13. mmarras commented on Dec 7, 2024

    @mmarras
    Author

    Successfully installed async-timeout-5.0.1 choreographer-0.99.7 kaleido-1.0.0rc0 simplejson-3.19.3

    I can report error persist, i.e. still hangs idefinitly.

  14. gvwilson commented on Apr 1, 2025

    @gvwilson
    Contributor

    can this one now be closed as out of date?

  15. mmarras commented on Apr 1, 2025

    @mmarras
    Author

    Let me check.

  16. gvwilson commented on Apr 29, 2025

    @gvwilson
    Contributor

    closed as no longer relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2TNGactivebug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions