Windows10下RStudio中Reticulate+Keras+TensorFlow环境配置疑问
关于R/RStudio下Python环境搭建的疑问
问题背景
在Windows 10系统中搭建R/RStudio与Python的协同环境时遇到大量问题,多种安装组合尝试后仍无法解决:
- 通过
reticulate::uninstall_miniconda()彻底清除电脑中的Python痕迹,更新所有R包并重装reticulate - 使用
reticulate::install_miniconda()安装Miniconda(作为新手,参考多数文档选择conda管理环境) - 安装最新
tensorflow包后执行install_tensorflow(),出现mapply()错误;安装keras包后执行install_keras(),同样出现该错误 - 尝试激活"r-reticulate"conda环境、调整tensorflow/keras安装顺序等操作均无效,随后在GitHub看到官方推荐的安装步骤:
install.packages("remotes") remotes::install_github(sprintf("rstudio/%s", c("reticulate", "tensorflow", "keras"))) if (is.null(reticulate::virtualenv_starter())) reticulate::install_python() keras::install_keras()
使用该步骤后,环境搭建成功。
核心疑问
- Posit/RStudio为何推荐使用
install_python()而非install_miniconda()? - 为何使用
install_python()后无需额外配置(如设置RETICULATE_PYTHON环境变量或执行use_python()),install_keras()就能成功,而使用install_miniconda()后却全部失败?
Session 信息
> sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.1.2 cli_3.6.1 tools_4.1.2 rstudioapi_0.15.0 rlang_1.1.1
内容的提问来源于stack exchange,提问作者quickreaction
相关产品推荐
相关产品推荐

