Error in value[[3L]](cond): Python virtual environment Directory can't be recognized after ShinyApp deployed

shiny
rstudio
shinyappsio

#1

...I wrote a ShinyApp to display the results of python scripts by creating a python virtual environment, The Shiny code works well on my own computer, and it also can be deployed. But when I opened the url after the deployment, a error appeared as follow:


It shows that the python virtual environment folder I created is not what it is. But there was no error when I run it locally. Here is my part of code:

path <- "C:/Users/wdeng/Desktop/cases/case_AE/ShinyApp"
use_python(paste(path,'/myvenv/Scripts/python.exe', sep = ''))
use_virtualenv(paste(path,'/myvenv/',sep = ''), required = TRUE)
source_python(paste(path,"/AE_products_checks.py",sep = ''))
source_python(paste(path,"/doc2docx.py",sep = ''))

#2

See the Troubleshooting section of the documentation, in particular the part about relative versus absolute paths.

Also, shinyapps.io runs Linux, so use_python with a .exe is not going to work either.


#3

Thanks so much, I have checked the Troubleshooting you mentioned in the reply and discarded applying use_python with a.exe, but the problem is still unresolved.

# use_python('myvenv/Scripts/python.exe')
use_virtualenv('venv', required = TRUE)
source_python("AE_products_checks.py")
source_python("doc2docx.py")
source("ui.R")
source('sever.R')

#4
use_virtualenv('venv', required = TRUE)
source_python("AE_products_checks.py")
source_python("doc2docx.py")
source("ui.R")
source('sever.R')

The absolute directory has been changed into relative one, and the whole project works well in the local computer.


#5

You need to make the virtualenv in shinyapps.io before you can use it.


#6

I'm not sure what you mean by making the virtualenv in shinyapps.io, actually, I have bundled all required files when I deployed the app. The following action is what I have done before using it.!
1544496144(1)


#7

Uploading your virtualenv is not likely to result in success either, since there is likely compiled code that works on whatever you are running locally, e.g. Windows, that will not work on shinyapps.io which runs Linux.

There is work underway in the rsconnect package to capture Python packages. Once that is released, there will need to be work on shinyapps.io to install them.

In the meantime, you will need to create the virtualenv and install the packages in the code that you deploy to shinyapps.io.


#8

Thank you so much for all your clarifying and spending time helping me figure out where my problems locate .