Skip to content

save_image Error #2494

Description

@msgoussi

Dear All,
I am using R 4.6, and i run the following code

 reticulate::use_python(reticulate::install_python())
 reticulate::py_require(c("kaleido", "plotly"))
  p <- plot_ly(x = 1:10)
  tmp <- tempfile(fileext = ".png")
  save_image(p, tmp)

I get the following error

Error in py_run_string_impl(code, local, convert) : 
    File "<string>", line 1
    import json; fig = json.load(open('C:\Users\310677\AppData\Local\Temp\Rtmpq0iC7T\filec73864b9a23.json'))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Run `reticulate::py_last_error()` for details.

then i run r reticulate::py_last_error()

reticulate::py_last_error() ── Python Exception Message ─────────────────────────────────────────────────────────────────────────────── File "", line 1 import json; fig = json.load(open('C:\Users\310677\AppData\Local\Temp\Rtmpq0iC7T\filec73864b9a23.json')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape ── R Traceback ──────────────────────────────────────────────────────────────────────────────────────────── ▆ 1. └─plotly::save_image(p, tmp) 2. └─kaleido()$transform(...) 3. └─reticulate::py_run_string(load_json) 4. └─reticulate:::py_run_string_impl(code, local, convert) See `reticulate::py_last_error()$r_trace$full_call` for more details. --   > | > >

Please advise.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions