You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
save_image not working. 'sys' is not defined in py_run_string_impl #2179
This seems to be some kind of regression with latest reticulate 1.26. It was also reported on Stack Overflow.
With reticulate 1.25 it works as usual:
remotes::install_github("rstudio/[email protected]")
#> Using github PAT from envvar GITHUB_PAT#> Downloading GitHub repo rstudio/[email protected]#> #> * checking for file ‘/tmp/RtmpIYtuHK/remotes13a887430565e/rstudio-reticulate-38978a1/DESCRIPTION’ ... OK#> * preparing ‘reticulate’:#> * checking DESCRIPTION meta-information ... OK#> * cleaning src#> * checking for LF line-endings in source and make files and shell scripts#> * checking for empty or unneeded directories#> * building ‘reticulate_1.25.tar.gz’#> Installing package into '/home/salim/.by_pkg_mngr/r'#> (as 'lib' is unspecified)
library(plotly)
#> Loading required package: ggplot2#> #> Attaching package: 'plotly'#> The following object is masked from 'package:ggplot2':#> #> last_plot#> The following object is masked from 'package:stats':#> #> filter#> The following object is masked from 'package:graphics':#> #> layoutp<- plot_ly(x=1:10)
save_image(p, "./pic.png")
#> No trace type specified:#> Based on info supplied, a 'histogram' trace seems appropriate.#> Read more about this trace type -> https://plotly.com/r/reference/#histogram
A workaround for reticulate 1.26 is to call import sys in Python before executing save_img():
install.packages("reticulate")
#> Installing package into '/home/salim/.by_pkg_mngr/r'#> (as 'lib' is unspecified)
library(plotly)
#> Loading required package: ggplot2#> #> Attaching package: 'plotly'#> The following object is masked from 'package:ggplot2':#> #> last_plot#> The following object is masked from 'package:stats':#> #> filter#> The following object is masked from 'package:graphics':#> #> layoutp<- plot_ly(x=1:10)
reticulate::py_run_string("import sys")
save_image(p, "./pic.png")
#> No trace type specified:#> Based on info supplied, a 'histogram' trace seems appropriate.#> Read more about this trace type -> https://plotly.com/r/reference/#histogram
#Error in py_run_string_impl(code, local, convert) :
#NameError: name 'sys' is not defined
reticulate::py_run_string("import sys")
finally, NO COMPLAIN
Activity
salim-b commentedon Sep 7, 2022
This seems to be some kind of regression with latest reticulate 1.26. It was also reported on Stack Overflow.
With reticulate 1.25 it works as usual:
Created on 2022-09-07 with reprex v2.0.2
A workaround for reticulate 1.26 is to call
import sysin Python before executingsave_img():Created on 2022-09-07 with reprex v2.0.2
lucius81 commentedon Sep 14, 2022
This has worked for me:
library(reticulate)
reticulate::py_run_string("import sys")
Thanks a lot!
Dave-stack commentedon Nov 7, 2022
#Error in py_run_string_impl(code, local, convert) :
#NameError: name 'sys' is not defined
reticulate::py_run_string("import sys")
finally, NO COMPLAIN
cpsievert commentedon Feb 13, 2023
Fixed by #2228