【发布时间】:2022-01-13 23:10:55
【问题描述】:
我无法通过 R reticulate 安装 gekko 包。我的 R 版本是 3.4.4,我的 Python 版本是 3.8.8,我在 Python 中使用 Gekko 没有问题。所以我尝试用我知道的这两种方式在 R 上安装:
-
py_install("gekko")
-
reticulate::conda_install("my_conda_environment", "gekko")
但是,在这两种情况下,我都会收到以下相同的错误。
PackagesNotFoundError:当前频道无法提供以下软件包:
- 壁虎
当前频道:
- https://conda.anaconda.org/root/win-64
- https://conda.anaconda.org/root/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
我没有在 Anaconda 文档中找到其他替代方法。我该如何解决这个问题?
编辑:我根据 John Hedengren 的回答和 reticulate docs 中的参考资料解决了我的问题。为此,我需要创建一个新环境来使用 R 中的以下代码指定 Python 版本和包:
reticulate::py_install(
packages = c(
"numpy",
"pandas", # Or another packages that you need
"gekko"
),
envname = "r-gekko",
method = "conda", # On Windows, the 'conda' method is always used
python_version = "3.8.8",
pip = TRUE # It's mandatory to install gekko
)
【问题讨论】:
标签: python r anaconda gekko reticulate