plotly / plotly/plotly.R

save_image Error

Đang mở
#2,494 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
R
Star
2.7k
Fork
641
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ plotly::save_image(p, tmp), lần theo kaleido()$transform đến reticulate::py_run_string(load_json); tái hiện lỗi trên Windows với đường dẫn tạm thời được hiển thị. Hoàn tất khi JSON được tải thành công và save_image ghi PNG mà không gặp lỗi unicodeescape của Python.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python, r
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.