Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RStudio crashes when calling reticulate::py_config() #2030

Open
ioanavicGIT opened this issue Oct 15, 2024 · 2 comments
Open

RStudio crashes when calling reticulate::py_config() #2030

ioanavicGIT opened this issue Oct 15, 2024 · 2 comments

Comments

@ioanavicGIT
Copy link

I know there are several other issues with the same topic but what i found was not clear to me what versions of RStudio, Python, reticulate or other packages were used.
So I will describe my issue and I would kindly ask for a tutorial or reproduceable step by step guide to setup in RStudio an RPackage project that uses renv and successfully integrates python via reticulate.

Here is what i did:

1. Setup the RPackage project

  • open R
  • run:
    usethis::create_package('[[prj path]]')
  • a new project is created and opened in a new RSession
  • run:
    renv::init()
    renv::activate()
  • the R session restarts and the package has the structure updated
  • installed devtools
    install.packages("devtools")

2. Install reticulate

  • first tried
    usethis::use_package("reticulate")
    But this installs the latest version of reticulate. After some reading for debugging different issues, have tried different version of reticulate, different versions of Rcpp etc.. So i ended up installing older versions of Rcpp and reticulate (exactly in this order as some articles suggested)
detach("package:reticulate", unload = TRUE)
remove.packages("reticulate")
remove.packages("Rcpp")
install.packages("Rcpp_1.0.9.tar.gz", repos=NULL, type="source")
install.packages("reticulate_1.26.tar.gz", repos=NULL, type="source")

  • at this point the package successfully builds

3. Set up Python integration

renv::use_python()
renv::status()
renv::snapshot()
  • these commands created a python structure under renv folder and updated renv.lock and created requirements.txt
  • at this point the package successfully builds

The crash

  • I use devtools to load my package:
    devtools::load_all()
  • I successfully run
    reticulate::py_discover_config()
    Outcome
    python: …/myproj/renv/python/virtualenvs/renv-python-3.11/Scripts/python.exe
    libpython: C:/Program Files/Python/Python311/python311.dll
    pythonhome: …/myproj/renv/python/virtualenvs/renv-python-3.11
    version: 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]
    Architecture: 64bit
    numpy: …/myproj/renv/python/virtualenvs/renv-python-3.11/Lib/site-packages/numpy
    numpy_version: 2.1.2
  • running reticulate::py_version() returns nothing
  • running reticulate::py_available() returns false
  • running reticulate::py_config() crashes RStudio

I am using the latest version of RStudio: 2024.09.0 Build 375, but in the process I have tried different versions of RStudio with the same result.

Thank you in advance for your support!

@t-kalinowski
Copy link
Member

This question might be better suited for renv. @kevinushey, is it okay to move it?

@kevinushey kevinushey transferred this issue from rstudio/reticulate Oct 30, 2024
@kevinushey
Copy link
Collaborator

Good idea, I've transferred the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants