Os GS
Os GS

Reputation: 69

How do I access Anaconda environment from R reticulate if it is in my WSL home directory?

I have a working anaconda distribution (can install conda environments/packages and use them in Python). Now I'm trying to use an anaconda environment in Rstudio using the reticulate library but it can't seem to find my anaconda environments. I use the Windows Subsystem for Linux (WSL).

Here is the what happens when I look at my environments in WSL:

conda env list

conda environments: # base /home/osgrinds/mnt/c/Users/Owner/anaconda3

emcee_env
/home/osgrinds/mnt/c/Users/Owner/anaconda3/envs/emcee_env
py_conda_test
/home/osgrinds/mnt/c/Users/Owner/anaconda3/envs/py_conda_test
pymc3Env
/home/osgrinds/mnt/c/Users/Owner/anaconda3/envs/pymc3Env
pymc3_env
/home/osgrinds/mnt/c/Users/Owner/anaconda3/envs/pymc3_env
pymc_env
/home/osgrinds/mnt/c/Users/Owner/anaconda3/envs/pymc_env

And now, when I try to see these environments in R using reticulate (and in a R markdown file):

library(reticulate)
myenvs=conda_list()
print(myenvs)
      name                                                                       python 1            3                               

C:\Users\Owner\.julia\conda\3/python.exe 2 mcmcEnv
C:\Users\Owner\.julia\conda\3\envs\mcmcEnv/python.exe 3
base
C:\Users\Owner\AppData\Local\r-miniconda/python.exe 4 r-reticulate C:\Users\Owner\AppData\Local\r-miniconda\envs\r-reticulate/python.exe 5 PyMOL2
C:\Users\Owner\Schrodinger\PyMOL2/python.exe

As you can see, none of my conda environments are there. Plus, I have tried specifying which conda to use with this command:

use_condaenv("pymc_env")

Error in use_condaenv("pymc_env") : Unable to locate conda environment 'pymc_env'.

But it can't find it. And I can't specify the path either, because it is under a path from my WSL home. Here is an example:

use_condaenv("\\wsl$\Ubuntu\home\osgrinds\mnt\c\Users\Owner\anaconda3\envs\pymc_env\bin\python")

Error: '\h' is an unrecognized escape in character string starting ""\wsl$\Ubuntu\h"

Is there a way to work around this?

Upvotes: 3

Views: 551

Answers (1)

user418560
user418560

Reputation: 51

The two OS seem to be independant. I guess, RStudio is installed on the Linux system. Maybe installing Rstudio on WSL too can be a solution.

Upvotes: 0

Related Questions