Start Rstudio Server session in conda environment

rstudioserver
anaconda

#1

If I start Rstudio at the command line from within a conda environment, the IDE loads with all my packages and paths set up correctly.

Is there a way I could have an Rstudio Server session start in a conda environment? I tried putting a .Renviron file in the project home with source activate <env>, but that didn't do it.

Also, I've tried reticulate and it flat out doesn't function.

Is there a way to have Rstudio Server start my session in a specific conda environment?


#2

Do you plan to use reticulate on the server ?
If so, you should read this article
https://rstudio.github.io/reticulate/articles/versions.html
By configuring RETICULATE_PYTHON environment variable on the server, it will always use the same python version. You can configure with Sys.getenv in .Rprofile or using .Renviron, for your user. A server admin can also do this server-wide.

use_conda function is another lighter option to put in your projects.

If you don’t use reticulate, you may be able to configure your session profile on their server to activate an environment at the beginning of your session.
If you have rstudio server pro, there is a config file to do that at the start of an r session in rstudio server.

Hope it helps


#3

@cderv -- I have tried reticulate, but unfortunately, it doesn't actually work.

> library(reticulate)
> use_condaenv('dada2')
> system('conda list | grep dada2')
# packages in environment at /home/balter/conda/envs/dada2:
bioconductor-dada2        1.6.0                  r3.4.1_0    bioconda
> library(dada2)
Error in library(dada2) : there is no package called ‘dada2’

#4

The problem here is that no :package: dada2 is installed on your R libraries. Did you try to import this as python :package: in R? If so, I think you should use reticulate::import
example

library(reticulate)
os <- import("os")
os$listdir(".")

Also, you can use reticulate::conda_list() to list the available conda environment.
When trying to load an environment, I think you should put the exact name, here bioconductor-dada2 according to you example. Also, if you want to be sure that it is loaded, you can use required = TRUE in use_condaenv to get an error if it fails located the correct python version. See ?use_condaenv
Can you try again whith these infos ?