Closed Adafede closed 1 year ago
While running more in-depth could reach the following, can maybe help:
Detailed traceback:
File "<string>", line 1, in <module>
File "/Users/rutza/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/kaleido/scopes/plotly.py", line 153, in transform
response = self._perform_transform(
File "/Users/rutza/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/kaleido/scopes/base.py", line 293, in _perform_transform
self._ensure_kaleido()
File "/Users/rutza/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/kaleido/scopes/base.py", line 198, in _ensure_kaleido
raise ValueError(message)
Calls: <Anonymous> -> <Anonymous> -> <Anonymous> -> py_run_string_impl
Execution halted
I believe I'm having the same issue- my R instance hangs when trying to save a static image. Nothing I've tried seems to fix the issue. I've tried installing a separate instance of Anaconda in a location without spaces in the directory path, re-installing packages, etc.
I'm having the same issue. I get teh same error as in above code. If I use a path instead of just a file name save_image(p, tempfile(fileext = ".png"))
I get:
Error in py_run_string_impl(code, local, convert) :
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (<string>, line 1)
I did discovere the issue after transfering to a new computer. Previously it worked fine.
> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=Finnish_Finland.utf8 LC_CTYPE=Finnish_Finland.utf8 LC_MONETARY=Finnish_Finland.utf8
[4] LC_NUMERIC=C LC_TIME=Finnish_Finland.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plotly_4.10.0 ggplot2_3.3.5 testthat_3.1.4 devtools_2.4.3 usethis_2.1.5
loaded via a namespace (and not attached):
[1] bitops_1.0-7 fs_1.5.2 statfitools_0.3.7.9003 lubridate_1.8.0
[5] fontawesome_0.2.2 httr_1.4.2 rprojroot_2.0.3 googleAuthR_2.0.0
[9] tools_4.2.0 backports_1.4.1 utf8_1.2.2 R6_2.5.1
[13] DBI_1.1.2 lazyeval_0.2.2 colorspace_2.0-3 withr_2.5.0
[17] tidyselect_1.1.2 prettyunits_1.1.1 processx_3.5.3 curl_4.3.2
[21] compiler_4.2.0 cli_3.3.0 desc_1.4.1 scales_1.2.0
[25] callr_3.7.0 askpass_1.1 rappdirs_0.3.3 stringr_1.4.0
[29] digest_0.6.29 rmarkdown_2.14 pkgconfig_2.0.3 htmltools_0.5.2
[33] sessioninfo_1.2.2 fastmap_1.1.0 htmlwidgets_1.5.4 rlang_1.0.2
[37] readxl_1.4.0 pttrobo_0.1.7 rstudioapi_0.13 generics_0.1.2
[41] zoo_1.8-10 jsonlite_1.8.0 crosstalk_1.2.0 dplyr_1.0.8
[45] zip_2.2.0 car_3.0-12 RCurl_1.98-1.6 magrittr_2.0.3
[49] Matrix_1.4-1 Rcpp_1.0.8.3 munsell_0.5.0 fansi_1.0.3
[53] abind_1.4-5 reticulate_1.24 lifecycle_1.0.1 stringi_1.7.6
[57] yaml_2.3.5 carData_3.0-5 brio_1.1.3 pkgbuild_1.3.1
[61] grid_4.2.0 forcats_0.5.1 crayon_1.5.1 lattice_0.20-45
[65] knitr_1.39 ps_1.7.0 pillar_1.7.0 ggpubr_0.4.0
[69] ggsignif_0.6.3 pkgload_1.2.4 glue_1.6.2 evaluate_0.15
[73] data.table_1.14.2 remotes_2.4.2 png_0.1-7 vctrs_0.4.1
[77] cellranger_1.1.0 gtable_0.3.0 robonomistClient_2.2.4 openssl_2.0.0
[81] purrr_0.3.4 tidyr_1.2.0 assertthat_0.2.1 cachem_1.0.6
[85] xfun_0.30 googleCloudStorageR_0.7.0 broom_0.8.0 rstatix_0.7.0
[89] later_1.3.0 viridisLite_0.4.0 gargle_1.2.0 tibble_3.1.6
[93] websocket_1.4.1 memoise_2.0.1 ellipsis_0.3.2 here_1.0.1
I can't get this to run on my MacBook Pro M1 either.
p <- plot_ly(x = 1:10, y = 1:10, type = "scatter", mode = "marker")
save_image(p, "test.png")
Error in py_run_string_impl(code, local, convert) :
NameError: name 'sys' is not defined
I went through all the installation steps in ?plotly::save_image
without issues.
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')
I tried reticulate::import("sys")
but that didn't work. Any help would be appreciated.
@mnneely I am having the same problem
Error in py_run_string_impl(code, local, convert) : NameError: name 'sys' is not defined
reticulate::py_run_string("import sys")
it work!!!
Using Windows 10 and running this causes R to hang and does not render the test p:
library(reticulate)
use_miniconda('r-reticulate')
library(plotly)
p <- plot_ly(x = 1:10, y = 1:10, type = "scatter", mode = "marker")
save_image(p, "test.png")
Here is the traceback:
traceback(save_image(p, "test.png"))
Error in py_run_string_impl(code, local, convert) :
NameError: name 'sys' is not defined
Run `reticulate::py_last_error()` for details.
> reticulate::py_last_error()
-- Python Exception Message --------------------------------------------------------
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'sys' is not defined
-- R Traceback ---------------------------------------------------------------------
x
1. +-base::traceback(save_image(p, "test.png"))
2. | \-base::.traceback(x, max.lines = max.lines)
3. | \-base (local) .is.positive.intlike(x)
4. \-plotly::save_image(p, "test.png")
5. \-kaleido()$transform(...)
6. \-reticulate::py_run_string(...)
7. \-reticulate:::py_run_string_impl(code, local, convert)
Current R version and sessionInfo:
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Workspace loaded from ~/.RData]
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.10 mathjaxr_1.6-0 pillar_1.9.0
[4] compiler_4.1.2 tools_4.1.2 metadat_1.2-0
[7] nlme_3.1-153 jsonlite_1.8.7 lifecycle_1.0.3
[10] tibble_3.2.1 gtable_0.3.3 lattice_0.20-45
[13] pkgconfig_2.0.3 png_0.1-8 rlang_1.1.1
[16] Matrix_1.5-4 cli_3.6.1 rstudioapi_0.14
[19] gridExtra_2.3 metafor_4.2-0 dplyr_1.1.2
[22] generics_0.1.3 vctrs_0.6.3 grid_4.1.2
[25] tidyselect_1.2.0 reticulate_1.31 glue_1.6.2
[28] R6_2.5.1 fansi_1.0.4 distributional_0.3.2
[31] purrr_1.0.1 ggplot2_3.4.2 farver_2.1.1
[34] magrittr_2.0.3 scales_1.2.1 ggdist_3.2.1
[37] colorspace_2.1-0 numDeriv_2016.8-1.1 utf8_1.2.3
[40] munsell_0.5.0 crayon_1.5.2
rstudioapi::versionInfo()
$citation
To cite RStudio in publications use:
Posit team (2023). RStudio: Integrated Development Environment for R.
Posit Software, PBC, Boston, MA. URL http://www.posit.co/.
A BibTeX entry for LaTeX users is
@Manual{,
title = {RStudio: Integrated Development Environment for R},
author = {{Posit team}},
organization = {Posit Software, PBC},
address = {Boston, MA},
year = {2023},
url = {http://www.posit.co/},
}
$mode
[1] "desktop"
$version
[1] ‘2023.6.2.561’
$long_version
[1] "2023.06.2+561"
$release_name
[1] "Mountain Hydrangea"
Thanks for all the digging!
Did you try the extra step I mentioned in the help for export_plotly
?
You need to include reticulate::py_run_string("import sys")
to avoid that error. I had the same problem on my Mac.
Altogether the commands are:
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')
reticulate::py_run_string("import sys") #this is the extra step neglected in help for save_plotly.
My export_plotly()
should run whichever of these is needed, but perhaps that part failed. I check to see if kaleido, reticulate, and minconda are installed, but maybe if there was a partial install the check failed and the installation wasn't completed.
Thansk @mnneely.
It seems like my issue might have had to do with this: https://stackoverflow.com/questions/72197496/r-plotlysave-image-kaleido-static-export-from-r-not-working
After failing to get tmp.png with the default kalido install I backed up to an older version:
reticulate::conda_install('r-reticulate', 'python-kaleido') # not working
reticulate::conda_install('r-reticulate', 'python-kaleido==0.1.*') # works
I don't know what the issue is or why it kept on hanging though...
Good find, but frustrating I agree. I have python-kaleido 0.2.1 running on my Mac (M1) and it works. I used reticulate::py_list_packages()
as an easy way to list all the Python packages installed via reticulate::conda_install()
.
Thanks Michael,
I am running as follows:
reticulate::py_list_packages() package version requirement channel 1 bzip2 1.0.8 bzip2=1.0.8 conda-forge 2 ca-certificates 2023.7.22 ca-certificates=2023.7.22 conda-forge 3 intel-openmp 2023.2.0 intel-openmp=2023.2.0 conda-forge 4 kaleido-core 0.1.0 kaleido-core=0.1.0 conda-forge 5 libblas 3.9.0 libblas=3.9.0 conda-forge 6 libcblas 3.9.0 libcblas=3.9.0 conda-forge 7 libffi 3.4.2 libffi=3.4.2 conda-forge 8 libhwloc 2.9.2 libhwloc=2.9.2 conda-forge 9 libiconv 1.17 libiconv=1.17 conda-forge 10 liblapack 3.9.0 liblapack=3.9.0 conda-forge 11 libsqlite 3.43.0 libsqlite=3.43.0 conda-forge 12 libxml2 2.11.5 libxml2=2.11.5 conda-forge 13 libzlib 1.2.13 libzlib=1.2.13 conda-forge 14 mathjax 2.7.7 mathjax=2.7.7 conda-forge 15 mkl 2022.1.0 mkl=2022.1.0 conda-forge 16 numpy 1.25.2 numpy=1.25.2 conda-forge 17 openssl 3.1.2 openssl=3.1.2 conda-forge 18 pip 23.2.1 pip=23.2.1 conda-forge 19 plotly 5.16.1 plotly=5.16.1 plotly 20 pthreads-win32 2.9.1 pthreads-win32=2.9.1 conda-forge 21 python 3.9.17 python=3.9.17 conda-forge 22 python-kaleido 0.1.0 python-kaleido=0.1.0 conda-forge 23 python_abi 3.9 python_abi=3.9 conda-forge 24 setuptools 68.1.2 setuptools=68.1.2 conda-forge 25 tbb 2021.10.0 tbb=2021.10.0 conda-forge 26 tenacity 8.2.2 tenacity=8.2.2 pkgs/main 27 tk 8.6.12 tk=8.6.12 conda-forge 28 tzdata 2023c tzdata=2023c conda-forge 29 ucrt 10.0.22621.0 ucrt=10.0.22621.0 conda-forge 30 vc 14.3 vc=14.3 conda-forge 31 vc14_runtime 14.36.32532 vc14_runtime=14.36.32532 conda-forge 32 vs2015_runtime 14.36.32532 vs2015_runtime=14.36.32532 conda-forge 33 wheel 0.41.2 wheel=0.41.2 conda-forge 34 xz 5.2.6 xz=5.2.6 conda-forge
Working so far!
From: Michael Neely @.> Sent: Tuesday, August 29, 2023 1:32 PM To: plotly/Kaleido @.> Cc: Rhodes, Nathaniel @.>; Comment @.> Subject: Re: [plotly/Kaleido] static export from R not working (Issue #129)
[External email: Use caution with links and attachments]
Good find, but frustrating I agree. I have python-kaleido 0.2.1 running on my Mac (M1) and it works. I used reticulate::py_list_packages() as an easy way to list all the Python packages installed via reticulate::conda_install().
— Reply to this email directly, view it on GitHubhttps://github.com/plotly/Kaleido/issues/129#issuecomment-1697940101, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP775YJQF2K6VLULEZRB74LXXYYTFANCNFSM5ORQNALQ. You are receiving this because you commented.Message ID: @.**@.>>
[https://online.midwestern.edu/images/EmailFooter.png]
.. ..
Hi,
Looks like there is a little something not working but couldn't figure out what:
gives
Coud not find any hints with
Hope it is the right place to report 😄