Hello,
I am trying to create a shiny app based on shinyapps.io that uses a virtualenv with python3 but I am currently having trouble with shinyapps.io recognising the virtual environment.
I have followed this tutorial to build my app and it works locally: I can access the virtual environment (and when I use reticulate::py_config() it tells me its running on the virtualenv).
Nevertheless, when I try to run it with shinyapps.io I always run into the same problem:
Error in value[[3L]](cond) :
Directory /cloud/project/python35_env/ is not a Python virtualenv
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
My code is:
library(tidyverse)
library(lubridate)
library(shiny)
library(leaflet)
reticulate::use_virtualenv("/cloud/project/python35_env/", required = TRUE)
reticulate::source_python("getdatafunction.py")
I have created the virtual environment on the console as the tutorial suggests (and I have tried creating other virtual environments at the same time the server was called) yet my problem is always the same. The code I wrote in the console is:
reticulate::virtualenv_create("python35_env", python = "usr/bin/python3")
reticulate::virtualenv_install("python35_env", c("pandas", "numpy", "requests", "requests_aws4auth", "elasticsearch_dsl", "elasticsearch"))
I don't know what else I could try. I am currently running it on RStudio Cloud as you can appreciate, but when I tried on the local console the error was still the same. It is always failing to recognise the virtual environment as what it is.
The architecture of the project is:
Cloud > project. In project we have stored:
- app.R
- getdatafunction.py
- .Rprofile
- rsconnect
- python35_env
In .Rprofile I have this code:
# .RProfile
if (!Sys.info()[['sysname']] == 'Darwin'){
Sys.setenv(RETICULATE_PYTHON = '/cloud/project/python35_env')
}
Any idea about how I could solve this?