rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more

Home Page:http://rstudio.github.io/rsconnect/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to pre-install Python dependencies for reticulated project?

TengMCing opened this issue · comments

Hi,

I have successfully deployed a reticulated project with the following app.R, but when I include tensorflow in py_install(), the app will take too long to start up because of the installation and shinyapps.io will shut it down.

library(shiny)
library(ggplot2)

reticulate::py_install(c("numpy", "Pillow"),
                       envname = "r-web_interface",
                       method = c("virtualenv"))
reticulate::use_virtualenv("r-web_interface")

PIL <- reticulate::import('PIL')
np <- reticulate::import("numpy")

server <- function(input, output) { 
  output$py_config <- renderText(capture.output(reticulate::py_config()))
}

ui <- fluidPage(textOutput('py_config'))

shinyApp(ui, server)

Is there a way to pre-install all these Python dependencies at build time?

It seems like there is a solution provided at https://solutions.posit.co/write-code/reticulate/, but when I deploy the app with the RStudio button, the published app will ignore all the Python dependencies (I have downloaded and checked the manifest.json file of the deployed app).

And if I use rsconnect::writeManifest() first to generate manifest.json and requirements.txt, then deploy the app with the rsconnect cli - rsconnect deploy manifest manifest.json, the deployed app will not be able to find a Python interpreter at .venv/bin/python.