rstudio / reticulate

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

Error in GitHub Action Virtualenv_create with R-devel and Reticulate #1544

Open pbulsink opened 6 months ago

pbulsink commented 6 months ago

Hello, we have a recurrent error with reticulate for rdevel on ubuntu in our github action:

https://github.com/SCasanova/f1dataR/actions/runs/8149812048/job/22275075253

In particular, trying to create a virtualenv causes the following error:

Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
  invalid non-character version specification 'x' (type: double)
Calls: virtualenv_create ... as.numeric_version -> numeric_version -> .make_numeric_version

Other versions of R on the same platform (release and oldrel) and with specified (3.11) or generic (3.x) versions of python pass. R-Devel on other platforms (windows-latest/macos-latest) with specified (3.11) or generic (3.x) versions of python fail.

Code suffering the error:

      - name: setup r-reticulate venv
        shell: Rscript {0}
        run: |
          python_packages <- c("numpy", "fastf1")
          library(reticulate)
          virtualenv_create("r-reticulate", Sys.which("python"))
          virtualenv_install("r-reticulate", python_packages)
          path_to_python <- virtualenv_python("r-reticulate")
          writeLines(sprintf("RETICULATE_PYTHON=%s", path_to_python),
                     Sys.getenv("GITHUB_ENV"))
t-kalinowski commented 6 months ago

Thanks for reporting.

I beleive the development version of reticulate already has a fix for the latest r-devel. Do you still see the error if you install reticulate from main branch?

We'll have a new CRAN release in a few weeks time.

pbulsink commented 6 months ago

Thanks for that advice. I re-ran on GHA with reticulate from github and everything ran correctly.

For others who may experience the same issue and want to use reticulate from github instead of CRAN, I added the following lines before my setup-reticulate step (after r-lib/actions/setup-r-dependencies@v2):

      - name: Install remotes
        run: |
          Rscript -e "install.packages('remotes')"

      - name: Install dev reticulate from Github
        run: |
          Rscript -e "remotes::install_github('rstudio/reticulate')"