Hi,
I was trying to follow this guide on how to publish a shiny app
code that uses python
through reticulate
on RStudio Connect
.
What I did is create a virtualenv
in the same directory where the app.R
script is, which has both the server
and ui
parts as well as code that uses reticulate
in order to import
and use several python
packages, using the command:
conda create -p .venv python=3.7
I then installed all the python packages that app.R
is import
ing with reticulate
: numpy
, pandas
. scipy
, and scanpy
.
I then followed this post and created a .RProfile
file in the same directory where app.R
and .venv
are, which has:
Sys.setenv(RETICULATE_PYTHON = "~/.venv/bin/python3.7")
Then, in app.R
I have these lines:
reticulate::virtualenv_create(".venv", python = "python3.7")
reticulate::use_virtualenv('.venv',required = TRUE)
I'm also including in the publishing bundle a requirements.txt
file with these lines:
numpy==1.18.1
pandas==1.0.4
scipy==1.4.1
scanpy==1.5.1
When I publish, at deployment on the RStudio Connect server I get these messages:
2020/06/11 12:41:44.556541714 Using Packrat dir /opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.6.3
2020/06/11 12:41:45.352030580 Error in value[[3L]](cond) : error in running command
2020/06/11 12:41:45.352053668 Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
2020/06/11 12:41:45.352119182 Execution halted
The error above is preceded in the log by these messages:
06/11 13:45:10.237
warning: using reticulate but python was not specified; will use python at /usr/bin/python3
06/11 13:45:10.237
Did you forget to set the RETICULATE_PYTHON environment variable in your .Rprofile before publishing?
Any idea what's wrong?