Environment: Windows 7, ArcGIS Pro 2.1, R 3.5.1 with reticulate v1.10.
ArcGIS Pro comes with a pre-configured python 3 conda environment that I'm trying to access in R. Related questions here and at stackoverflow all seem to focus on a similar situation with ArcMap 10.x, but that uses python 2.7 and doesn't use conda, so they haven't been much help.
If I'm reading the reticulate
documentation correctly, the following should work:
library(reticulate)
arcpy3_dir <- 'C:/Program Files/ArcGIS/Pro/bin/Python'
use_condaenv(condaenv = file.path(arcpy3_dir, 'envs', 'arcgispro-py3'),
conda = file.path(arcpy3_dir, 'Scripts' ,'conda.exe'),
required = TRUE)
However, I'm getting an 'unable to locate conda environment' error.
There are some .bat files in the same directory as conda.exe that seem to do a lot of temporary messing about with system paths (more commentary here for an older version of ArcGIS Pro), but I don't know enough about shell scripts to clearly understand what they're doing. I think I need to set some environment variables with Sys.setenv()
, but I'm not sure which. I tried
Sys.setenv('CONDA_NEW_ENV' = 'C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3',
'CONDA_EXE' = file.path(arcpy3_dir, 'Scripts' ,'conda.exe'),
'CONDA_SCRIPTS' = file.path(arcpy3_dir, 'Scripts'))
but that doesn't appear to be sufficient.
Has anyone managed to successfully access the ArcGIS Pro conda environment in R, using reticulate
?