简体   繁体   English

RStudio 中的 Keras/Tensorflow 在 Miniconda 环境中未引用 Python

[英]Keras/Tensorflow in RStudio not referencing Python in Miniconda Environment

so I've been trying to use Keras with Miniconda on my machine for a few weeks now (in Rstudio) and I've still been unable to make significant progress.所以我一直在尝试在我的机器上使用 Keras 和 Miniconda 几个星期(在 Rstudio 中),但我仍然无法取得重大进展。

Most recently, here are the steps I followed:最近,这是我遵循的步骤:

  1. create an environment in Miniconda, using Python 3.6在 Miniconda 中创建一个环境,使用 Python 3.6
  2. Download R and RStudio (an older version, Version 3.6.0) into said environment and run them将 R 和 RStudio(旧版本,版本 3.6.0)下载到所述环境中并运行它们
  3. Install Keras into the environment (after Rcpp, Devtools etc)将 Keras 安装到环境中(在 Rcpp、Devtools 等之后)
  4. Attempt to install Tensorflow尝试安装 Tensorflow

But then I get the error message that my Python installation isn't found and the bindings aren't loaded.但随后我收到错误消息,提示找不到我的 Python 安装并且未加载绑定。 I've put the environment on the PATH, as well as the location where Python is and some folders within the environment.我已将环境放在 PATH 上,以及 Python 所在的位置以及环境中的一些文件夹。

I followed the advice given in a comment in my last post, which helped me to create the environment, but now Python isn't loading in Miniconda and I'm so so frustrated that I haven't been able to make this work.我遵循了我在上一篇文章中的评论中给出的建议,这帮助我创建了环境,但是现在 Python 没有加载到 Miniconda 中,我非常沮丧,以至于我无法完成这项工作。 Please help.请帮忙。

When I look for the Python version I get this:当我寻找 Python 版本时,我得到了这个:

C:\Users\NK>python --version [1] Python 3.8.4rc1

Here is the beginning of the code I'm running:这是我正在运行的代码的开头:

library(keras)
library(tensorflow)
library(reticulate)

use_python("C:\\Users\\NK\\AppData\\Local\\Microsoft\\WindowsApps", required=T)
Sys.setenv(RETICULATE_MINICONDA_PATH = "C:/mini/envs/r_3.6.0.1")
mnist <- dataset_mnist()

and I get this error:我得到这个错误:

Error: Installation of Python not found, Python bindings not loaded. Use reticulate::install_miniconda() if you'd like to install a Miniconda Python environment. even though I'm doing this entirely in a Miniconda environment.即使我完全在 Miniconda 环境中执行此操作。 I'm even opening RStudio straight from the Miniconda command prompt.我什至直接从 Miniconda 命令提示符打开 RStudio。

Some basic info: Dell XPS 15 running Windows 10, using RStudio一些基本信息:运行 Windows 10 的戴尔 XPS 15,使用 RStudio

Side question: Is there an easier way to do all this?附带问题:有没有更简单的方法来做这一切? It's been fatiguing.已经很累了。

I finally got it to work: Here were my steps for anyone who stumbles across this:我终于让它工作了:对于任何偶然发现这个问题的人来说,这是我的步骤:

  1. Reinstall Anaconda重新安装 Anaconda
  2. Create Anaconda Environment with Python 2.7 and R使用 Python 2.7 和 R 创建 Anaconda 环境
  3. Install Keras and Tensorflow packages and dependencies one by one into the environment through Anaconda通过Anaconda将Keras和Tensorflow包和依赖一一安装到环境中
  4. Install RStudio in the environment through Anaconda通过Anaconda在环境中安装RStudio
  5. use use_python("[env]", required=T) and Sys.setenv(RETICULATE_MINICONDA_PATH = "[env]") in any scripts you run using Keras在使用 Keras 运行的任何脚本中使用use_python("[env]", required=T)Sys.setenv(RETICULATE_MINICONDA_PATH = "[env]")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM