Last active
April 8, 2021 18:10
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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