rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.68k stars 328 forks source link

Setting up "reticulate" in R #1685

Closed nhavt closed 1 month ago

nhavt commented 1 month ago

Hi there, I have a problem when setting up "reticulate" in R. For example,

  library("reticulate")
  repl_python()

I got the following error:

Python 3.13.0 (C:/Users/xxx/Miniconda3/envs/SM_VS2024/python.exe)
Reticulate 1.39.0 REPL -- A Python interpreter in R.
Enter 'exit' or 'quit' to exit the REPL and return to R.
Exception ignored in PyObject_HasAttrString(); consider using PyObject_HasAttrStringWithError(), PyObject_GetOptionalAttrString() or PyObject_GetAttrString():
Traceback (most recent call last):
  File "A path to project\renv\library\windows\R-4.4\x86_64-w64-mingw32\reticulate\python\rpytools\call.py", line 6, in python_function
    return call_r_function(f, *args, **kwargs)
RuntimeError: <text>:1:2: unexpected input"

Do you have any suggestions on how to fix this issue? Below is my session info:


R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] reticulate_1.39.0

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        Matrix_1.7-0      lattice_0.22-6    glue_1.7.0        png_0.1-8        
 [6] lifecycle_1.0.4   cli_3.6.3         fansi_1.0.6       vctrs_0.6.5       grid_4.4.1       
[11] renv_1.0.7        withr_3.0.1       compiler_4.4.1    rstudioapi_0.16.0 tools_4.4.1      
[16] pillar_1.9.0      Rcpp_1.0.13       rlang_1.1.4       jsonlite_1.8.8 

Thank you very much in advance!

t-kalinowski commented 1 month ago

Hi, thanks for reaching out. Reticulate is not yet compatible with Python 3.13, which was released earlier this month. For now, please continue using Python 3.12 or an earlier version.

reticulate::install_python("3.12")
reticulate::virtualenv_create("r-reticulate", "3.12", force = TRUE)
t-kalinowski commented 1 month ago

The development version of reticulate now supports Python 3.13. To install it:

pak::pkg_install("rstudio/reticulate")

Please let us know if you encounter any further issues.