2017-05-19 40 views
0

我想在Winpython 3.4.4.amd64中安裝keras庫,在RStudio(通過reticulate和kerasR庫)。我在Windows 7 64位機器上工作。我也試圖與Winpython版本3.6.1.amd64R reticulate包在winpython中看不到keras庫

我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具有相同的結果。 我很有創意,非常樂意提供所有建議。

+0

我對這些軟件包一無所知,但* keras *已正確安裝在您的python 3.4中。檢查PowerShell:'「C:\ path \ to \ python.exe」'後面跟'import keras'。或者在IDLE或腳本中做同樣的事情。你有錯誤嗎? – Parfait

+1

上次我查了一下,Tensorflow在python-3.4上沒有在Windows上工作。 – stonebig

+0

在可用於winpython的Spyder IDE中,我可以導入keras,並將.python.json更改爲使用theano代替tensorfliw。也許從r python使用從不同位置讀取python.json?有沒有辦法檢查它? –

回答

1

關於安裝Keras的/ theano PLZ在SO

How do I install Keras and Theano in Anaconda Python on Windows?

檢查此線程

一旦完成重新啓動補償....然後讓嘗試kerasR來自R Studio連接下面給出 (按順序) ...........

##########深度學習安裝&開始
#### First activate environment where keras/theano were installed via anaconda prompt : 

(C:\Users\ADMIN\Anaconda3) C:\Users\ADMIN>activate mydeeplearningmydeeplearning是我安裝我的環境名稱蟒蛇keras theano等.....

然後從r工作室

嘗試安裝最新的GitHub包版本,而不是從CRAN .....

devtools::install_github("statsmaths/kerasR") 
devtools::install_github("rstudio/reticulate")# install the latest reticulate package as it solves some errors/bugs 

library(kerasR) 
library(reticulate) 

py_available(initialize = FALSE) # should give TRUE 

use_python("C:/Users/ADMIN/Anaconda3/envs/mydeeplearning/python.exe") # plz change it to your Path 
keras_init() # will give `successfully loaded keras` 

# further checks if everything is working 
keras_available() # should give `[1] TRUE` 
reticulate::py_config() # should show u]the correct python path which we tried changing initially using `use_python("C:/Users/ADMIN/Anaconda3/envs/mydeeplearning/python.exe") ` 

python:   C:/Users/ADMIN/Anaconda3/envs/mydeeplearning/python.exe 
libpython:  C:/Users/ADMIN/Anaconda3/envs/mydeeplearning/python35.dll 
pythonhome:  C:\Users\ADMIN\ANACON~1\envs\MYDEEP~1 
version:  3.5.3 |Continuum Analytics, Inc.| (default, May 15 2017, 10:43:23) [MSC v.1900 64 bit (AMD64)] 
Architecture: 64bit 
numpy:   C:\Users\ADMIN\ANACON~1\envs\MYDEEP~1\lib\site-packages\numpy 
numpy_version: 1.13.1 

python versions found: 
C:/Users/ADMIN/Anaconda3/envs/mydeeplearning/python.exe 
C:\PROGRA~1\Python35\python.exe 
C:\Users\ADMIN\ANACON~1\python.exe 
C:\PROGRA~1\Python35\\python.exe 
C:\Users\ADMIN\ANACON~1/envs/mydeeplearning/python.exe  

reticulate::py_module_available("keras") #should give `[1] TRUE` 
reticulate::py_available()#should give `[1] TRUE` 
reticulate::import("keras.models")# should give `Module(keras.models)` 

應該這樣做....我花了幾乎整整一天的安裝,並找出錯誤....但是現在感覺心花怒放.....

0

相若方式,我想,當有問題在WIN7下的Anaconda3 5.0.0中安裝R「keras」庫。

https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl一直未能在Python安裝3.6(運輸/車輪的問題),一直在尋找像蟒蛇3.6的兼容性問題,我做雖然檢查64位架構:

>>>import platform 
>>>platform.architecture() 

( '64',' WindowsPE')

將PYTHON從3.6降級到3。5暢達環境R-tensorflow和R中使用的網紋指向那個環境:use_condaenv("r-tensorflow")

https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp35-cp35m-win_amd64.whl版本難道不正常安裝沒有,只好用tensorflow-1.2.1-CP35-cp35m-win_amd64.whl在Python 3.5,該工作

問題是,install_keras()似乎調用install_tensorflow(method = "conda")實際上覆蓋,並使用PIP重新安裝tensorflow:

activate r-tensorflow && pip install --upgrade --ignore-installed "https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp35-cp35m-win_amd64.whl" 

我的猜測是,它是更好T選用「kerasR」而不是「keras」庫,然後嘗試執行tensorflow-1.2.1-py35。如果您發現解決方法,請發佈。