r网状指定python可执行
首先,我在Windows机器上工作。我想指定在Rstudio中使用的特定版本的Python。我希望Rstudio在ArcGIS Pro文件夹中使用Python 3,以便拥有arcpy
以及许可的扩展名。我已经安装了网状
,并尝试了以下方法迫使rstudio使用python的ArcGis Pro版本。
首先,我尝试了以下操作:
library(reticulate)
use_python("C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe", required = TRUE)
结果错误:
Error in path.expand(path) : invalid 'path' argument
遵循其他提示,我在加载网状库之前尝试设置环境。
Sys.setenv(RETICULATE_PYTHON = "c:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe")
library(reticulate)
然后,我检索有关网状使用当前正在使用的Python版本的信息。
py_config
Error in path.expand(path) : invalid 'path' argument
创建和编辑
usethis::edit_r_environ()
软件包来
RETICULATE_PYTHON="C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe"
。
library (reticulate)
py_config()
Error in path.expand(path) : invalid 'path' argument
关于我为什么继续接收无效的'PATH'参数
UPDATE(1/11/24)的任何想法:这似乎不是重新启用软件包。我当前的配置是R版本:4.3.2,网状版本:1.34.0,rstudio版本:2023.12.0,Arcgis Pro版本:3.2.0。
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...
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也有类似的问题。在尝试了各种各样的事情之后,我终于安装了 reticulate 的存档版本(reticulate_1.22),而不是使用最新版本(reticulate_1.23),现在问题消失了。看来这个错误已经引起了开发人员的注意(https://github.com/ rstudio/reticulate/issues/1189)。
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).
您是否尝试过用
PROGRA~1
替换Program Files
,并且您是否还检查过诸如dir("path/to/your/env") 这样的命令
虽然你的截图看起来不错;顺便说一句,以防万一 - 编辑 .Renviron 文件后,您需要重新启动 RStudio/R 会话才能使更改生效;

RStudio 版本 2022.02 现在在
全局选项
中提供了Python解释器
选择Have you tried replacing
Program Files
withPROGRA~1
and have you maybe also checked for example a command likedir("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 inGlobal Options
尝试使用
Try using
我在R-4.1.1版本中遇到了相同的错误,但是当我切换回前版本R-4.0.5时,一切都按预期工作。这是一个快速的解决方法,但不能解决当前版本中的基本问题。
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.