1

First, I'm working on a Windows machine. I would like to specify a specific version of python to use in RStudio. I would like RStudio to use python 3 in the ArcGIS Pro folder in order to have arcpy available, along with the licensed extensions. I have reticulate installed and have tried the following methods to force RStudio to use the ArcGIS Pro version of python.

First I tried this:

library(reticulate)
use_python("C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe", required = TRUE)

The resulting error:

Error in path.expand(path) : invalid 'path' argument

Following some other tips, I tried setting the environment before loading the reticulate library.

Sys.setenv(RETICULATE_PYTHON = "c:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe")
library(reticulate)

Then I retrieve information about the the version of Python currently being used by reticulate.

py_config
Error in path.expand(path) : invalid 'path' argument

I also tried creating and editing the .Renviron by using the usethis package

usethis::edit_r_environ()

Then entering the following

RETICULATE_PYTHON="C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe"

And saving it, restarting R..

library (reticulate)
py_config()
Error in path.expand(path) : invalid 'path' argument

And, to confirm, here is the location... enter image description here

Any ideas on why I continue to receive invalid 'path' argument

UPDATE (1/11/24): This doesn't seem to be an issue with the reticulate package anymore. My current configuration is R version: 4.3.2, reticulate version: 1.34.0, RStudio version: 2023.12.0, ArcGIS Pro version: 3.2.0.

4 Answers 4

2

I was having a similar issue. After trying a whole assortment of things, I finally installed an archived version of reticulate (reticulate_1.22) instead of using the most up-to-date version (reticulate_1.23) and now the issue is gone. It appears that this bug has been brought to the developers' attention (https://github.com/rstudio/reticulate/issues/1189).

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
2

Have you tried replacing Program Files with PROGRA~1 and have you maybe also checked for example a command like dir("path/to/your/env") although tbh your screenshot looks ok;

btw just in case - after editing your .Renviron file you need to restart your RStudio/R session for changes to take effect; RStudio version 2022.02 has Python interpreter selection now available in Global Options enter image description here

2 Comments

I just tried your suggestions, still the same error. My thought is that maybe something in my computer's system variables is creating this error. Unfortunately I don't have admin rights on this machine but will investigate my system variables and possibly delete path variable.
this could be the case if you installed some Python or Anaconda version that modifies your path? But you should be able to easily check that with Sys.getenv()
0

Try using

use_python("C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3")

1 Comment

Different error when using your suggestion. Error in system2(command = python, args = shQuote(script), stdout = TRUE, : '"C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3"' not found
0

I ran into the same error with R version R-4.1.1, but when I switched back to the previous version R-4.0.5 everything worked as expected. It's a quick workaround but doesn't solve the underlying issue in the current version.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.