【发布时间】:2017-10-19 15:29:47
【问题描述】:
我正在尝试在 RStudio 中使用安装在 Winpython 版本 3.4.4.amd64 中的 keras 库(通过 reticulate 和 kerasR 库)。我在 Windows 7 64 位机器上工作。我也尝试过使用 Winpython 3.6.1.amd64 版
我在 R 中尝试过的内容:
# diagnostics
library(reticulate)
# reticulate::use_python("PATH_TO_PYTHON")
path_to_python <- "C:\\dev\\WinPython3.4\\python-3.4.4.amd64"
use_python(path_to_python)
py_module_available("keras")
[1] FALSE # it responds with TRUE for eg. matplotlib
py_config()
# python: C:\dev\WinPython3.4\python-3.4.4.amd64/python.exe
# libpython: C:/dev/WinPython3.4/python-3.4.4.amd64/python34.dll
# pythonhome: C:\dev\WINPYT~1.4\PYTHON~1.AMD
# version: 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC # v.1600 64 bit (AMD64)]
# Architecture: 64bit
# numpy: C:\dev\WINPYT~1.4\PYTHON~1.AMD\lib\site-packages\numpy
# numpy_version: 1.11.3
当我使用 Spyder IDE 并加载 keras 时,它不会向我抛出错误。早些时候我注意修改 .keras json 文件以使用 theano 而不是 tensorflow。
当我尝试其他库时,例如 py_module_available("theano") 我得到 TRUE。
我不知道我在这里想念什么。我想将 keras 与库(kerasR)一起使用。我在工作,无法修改注册表和环境路径。会是这个原因吗?
当我尝试时
reticulate::import("keras")
我明白了:
Error in py_module_import(module, convert = convert) :
AttributeError: 'NoneType' object has no attribute 'write'
Detailed traceback:
File "C:\dev\WINPYT~1.4\PYTHON~1.AMD\lib\site-packages\keras\__init__.py", line 2, in <module>
from . import backend
File "C:\dev\WINPYT~1.4\PYTHON~1.AMD\lib\site-packages\keras\backend\__init__.py", line 66, in <module>
sys.stderr.write('Using TensorFlow backend.\n')
我对 3.6.1.amd64 进行了相同的尝试,结果相同。 我没有想法,非常感谢所有建议。
【问题讨论】:
-
我对这些软件包一无所知,但 keras 是否正确安装在您的 python 3.4 中。签入 PowerShell:
"C:\path\to\python.exe",后跟import keras。或者在 IDLE 或脚本中做同样的事情。你有错误吗? -
上次我检查时,Tensorflow 无法在 Windows 上运行 python-3.4。
-
在可用于 winpython 的 Spyder ide 中,我可以导入 keras,我将 .python.json 更改为使用 theano 而不是 tensorfliw。也许当从 r python 使用时从不同的位置读取 python.json?有没有办法检查?
标签: python r rstudio keras reticulate