Skip to content

Instantly share code, notes, and snippets.

@Kvit
Last active April 8, 2021 18:10
Show Gist options
  • Select an option

  • Save Kvit/91ceefbc6d300bb25437740eef876897 to your computer and use it in GitHub Desktop.

Select an option

Save Kvit/91ceefbc6d300bb25437740eef876897 to your computer and use it in GitHub Desktop.
Setting up python conda environment for R on Digital Ocean for Shiny Apps
## In shell (under root user): Run R as shyny user
runuser -l shiny -c 'R'
## in R session:
#istall reticulate
if (! require(reticulate)) install.packages('reticulate', dependencies = TRUE)
# init Python
reticulate::py_available(initialize = T)
# check path to conda binary
reticulate::conda_binary(conda = "auto")
# check config
reticulate::py_config()
# install dependencies
PYTHON_DEPENDENCIES = c( 'torch', 'allennlp')
reticulate::conda_install(packages = PYTHON_DEPENDENCIES, ignore_installed=TRUE, pip = TRUE )
# check python setup
Sys.which("python")
# quit R
q()
## in Shell: restart shiny server
sudo systemctl restart shiny-server
# install other R packages for all linux users
sudo su - -c "R -e \"install.packages('reticulate', repos='http://cran.rstudio.com/')\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment