Trouble using Python Packages with Reticulate and shinyapps.io

shiny
shinyappsio
reticulate

#1

I am trying to publish a Shiny app which uses Reticulate and other Python packages. However I don't know how to install Python packages on the shinyapps.io server.

When I load the package pandas or twitter and deploy the app with shinyapps, I get the following error.

Error in value[[3L]](cond) : ImportError: No module named pandas
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

Here is my code.

library(shiny)
library(reticulate)
import('pandas')
import('twitter')

source_python("twitter_api.py")
test_var = py$my_var

server <- function(input, output) { 
  output$test_text <- renderText(py$my_var)
}

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

shinyApp(ui, server)

If you run the app, you can see that I'm able to pass values from the python script to R on shinyapps.io, but I'm unable to import packages.

How can I use Python packages with shinyapps?


#2

I believe that you need to call py_install(c('pandas', 'twitter')) in order for those modules to be installed and importable.


#3

Thanks Josh, that worked!