我想在anaconda環境(OSX)上安裝keras,因爲我想用它與spyder - ipython。要做到這一點,我只使用pip install keras
(我已經有張量流)。在安裝完畢後,我從終端調用python 2.7,keras工作正常。但是,當我調用Python 3.5的Spyder和嘗試導入keras我收到: 沒有名爲模塊「keras」在Anaconda OSX上安裝Keras
我認爲這個問題可能與我的MacBook上的路徑,因爲which python
回報
/usr/local/bin/python2.7
而which python3.5 (or spyder)
返回
/Users/georgiospapadopoulos/anaconda/bin/python3.5
/Users/georgiospapadopoulos/anaconda/bin/spyder
而且,在pip install keras
表明
Requirement already satisfied: keras in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
我的〜/ .bash_profile中包含
# added by Anaconda3 2.4.0 installer
export PATH="/Users/georgiospapadopoulos/anaconda/bin:$PATH"
# added by Anaconda3 4.2.0 installer
export PATH="/Users/georgiospapadopoulos/anaconda/bin:$PATH"
export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$CUDA_HOME/lib"
export PATH="$CUDA_HOME/bin:$PATH"
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
#PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
PATH="/usr/local/bin/python:$PATH"
export PATH
如果你用Anaconda安裝了所有東西,這將會容易得多,那麼這種困惑就不會發生。我遇到了一個關於Anaconda和pip的類似問題。我使用pip安裝了Keras,而Theano和Tensorflow使用conda,但是當我使用Tensorflow後端導入Keras時,我遇到了錯誤。所以,我使用pip卸載Keras,並通過conda再次安裝它,並且它工作正常! – Sahar