rreticulate

R Reticulate: 'Unable to locate conda environment' when attempting to use_condaenv(required = TRUE)


I see variations of this question have been asked but none of the answers have resolved my problem. I'm using Windows 10, R version 3.6.2, RStudio version 1.2.5033, reticulate version 1.14

> library(reticulate)
> library(dplyr)

> conda_list()
          name                                                                        python
1  r-miniconda                     C:\\Users\\caleb\\AppData\\Local\\r-miniconda\\python.exe
2 r-reticulate C:\\Users\\caleb\\AppData\\Local\\r-miniconda\\envs\\r-reticulate\\python.exe

So I try to use the second item:

> conda_list()[[2]][2] %>%
+   use_condaenv(required = TRUE)

But I get the following error:

Error in use_condaenv(., required = TRUE) : 
  Unable to locate conda environment 'C:/Users/caleb/AppData/Local/r-miniconda/envs/r-reticulate/python.exe'.

Looking for available versions gets me:

> py_discover_config()
python:         C:/Users/caleb/AppData/Local/r-miniconda/envs/r-reticulate/python.exe
libpython:      C:/Users/caleb/AppData/Local/r-miniconda/envs/r-reticulate/python36.dll
pythonhome:     C:/Users/caleb/AppData/Local/r-miniconda/envs/r-reticulate
version:        3.6.10 |Anaconda, Inc.| (default, Jan  7 2020, 15:18:16) [MSC v.1916 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/caleb/AppData/Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
numpy_version:  1.18.1

This is my first attempt use Python from R so I'm confident this is a user-error issue but searching the error message and looking through related stack threads hasn't helped. Does anyone see what I'm doing wrong here?


Solution

  • The use_condaenv function expects an environment name, not the path to the python executable. So just use

    use_condaenv("r-reticulate")
    

    rather than trying to call use_condaenv("C:\\Users\\caleb\\AppData\\Local\\r-miniconda\\envs\\r-reticulate\\python.exe")