简体   繁体   中英

R plotly::save_image / kaleido : static export from R not working

I am trying to save a static image from a plotly graph using plotly::save_image(), but everytime I run this function, Rstudio gets stack (busy red icon) and needs to be restarted. There is not any error message displayed.

I have run the following commands and they all seem to have been installed correctly:

install.packages('reticulate')
reticulate::install_miniconda()
reticulate::conda_install('r-reticulate', 'python-kaleido')
reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')
reticulate::use_miniconda('r-reticulate')

RStudio gets stack in a busy (red circle) state when save_image(p, tmp) is run:

p <- plot_ly(x = 1:10)
save_image(p, "test.png")


Thank you for your help


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Additional information including sessionInfo() output:


System type: 64-bit operating system, x64-based processor

Edition: Windows 10 Enterprise
version: 21H2
Installed on: 29/04/2022

plotly version: 4.10.0
reticulate version: 1.24


R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
LC_COLLATE=English_New Zealand.utf8
LC_CTYPE=English_New Zealand.utf8

LC_M.NETARY=English_New Zealand.utf8
LC_NUMERIC=C

LC_TIME=English_New Zealand.utf8


attached base packages:
stats
graphics
grDevices
utils
datasets
methods
base


other attached packages:
plotly_4.10.0
ggplot2_3.3.5

loaded via a namespace (and not attached):
pillar_1.7.0
compiler_4.2.0
tools_4.2.0
digest_0.6.29
viridisLite_0.4.0
jsonlite_1.8.0
evaluate_0.15
lifecycle_1.0.1
tibble_3.1.6
gtable_0.3.0
pkgconfig_2.0.3
rlang_1.0.2
cli_3.3.0
DBI_1.1.2
yaml_2.3.5
xfun_0.30
fastmap_1.1.0
httr_1.4.2
withr_2.5.0
dplyr_1.0.8
knitr_1.39
generics_0.1.2
vctrs_0.4.1
htmlwidgets_1.5.4
grid_4.2.0
tidyselect_1.1.2
glue_1.6.2
data.table_1.14.2 R6_2.5.1
fansi_1.0.3
rmarkdown_2.14
bookdown_0.26
tidyr_1.2.0
purrr_0.3.4
magrittr_2.0.3
scales_1.2.0
ellipsis_0.3.2
htmltools_0.5.2
assertthat_0.2.1
colorspace_2.0-3
utf8_1.2.2
lazyeval_0.2.2
munsell_0.5.0
crayon_1.5.1

I hope this still helps, I think I found the solution. Apparently in windows 10 and 11, you need an older version of kaleido. To get it, instead of: reticulate::conda_install('r-reticulate', 'python-kaleido') try reticulate::conda_install('r-reticulate', 'python-kaleido==0.1.*')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM