r网状指定python可执行

发布于 2025-01-17 19:16:16 字数 1438 浏览 5 评论 0原文

首先,我在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

我还尝试通过使用usethis ..

关于我为什么继续接收无效的'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...
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入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).

各自安好 2025-01-24 19:16:16

您是否尝试过用 PROGRA~1 替换 Program Files ,并且您是否还检查过诸如 dir("path/to/your/env") 这样的命令 虽然你的截图看起来不错;

顺便说一句,以防万一 - 编辑 .Renviron 文件后,您需要重新启动 RStudio/R 会话才能使更改生效;
RStudio 版本 2022.02 现在在全局选项中提供了Python解释器选择
输入图片此处描述

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

无声静候 2025-01-24 19:16:16

尝试使用

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

Try using

use_python("C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3")
挽袖吟 2025-01-24 19:16:16

我在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文