save_image Error

未關閉
#2,494 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
52/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
python, r

研究方向

從 plotly::save_image(p, tmp) 開始,追蹤 kaleido()$transform 到 reticulate::py_run_string(load_json);使用所示的暫存路徑在 Windows 上重現該失敗。完成條件是 JSON 成功載入,且 save_image 寫入 PNG 時不會出現 Python unicodeescape 錯誤。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
R
星號
2.7k
分支
641
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

plotly/plotly.R 的其他 Issue

查看 plotly/plotly.R 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。