在R中运行Keras时遇到问题。运行mnist <- dataset_mnist()
时出现错误Error: ModuleNotFoundError: No module named 'keras'
我已经安装了最新版本的Anaconda,我正在RStudio 1.1.463中运行R版本3.5.1。在R中,我已经跑步
library("keras")
install_keras()
这成功了。
尝试运行mnist <- dataset_mnist()
时,最初收到以下错误消息:
ImportError: No module named keras
Use the install_keras() function to install the core Keras library
Error: Error loading Python module keras
运行时
library(reticulate)
py_config()
我得到以下输出:
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
keras: [NOT FOUND]
查看了其他主题的建议解决方案后,我将此行添加到了.Rprofile
Sys.setenv(RETICULATE_PYTHON = "/anaconda3/envs/r-tensorflow/bin")
但是,当我现在运行mnist <- dataset_mnist()
时,出现以下错误:
Error: Python module keras was not found.
Detected Python configuration:
python: /anaconda3/envs/r-tensorflow/bin/python
libpython: /anaconda3/envs/r-tensorflow/lib/libpython3.6m.dylib
pythonhome: /anaconda3/envs/r-tensorflow:/anaconda3/envs/r-tensorflow
version: 3.6.7 | packaged by conda-forge | (default, Nov 20 2018, 18:37:09) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: [NOT FOUND]
keras: /anaconda3/envs/r-tensorflow/lib/python3.6/site-packages/keras
NOTE:
有人知道我该怎么做吗?