簡體   English   中英

如何在 Anaconda (Jupyter) 中安裝 Theano 和 Lasagne?

[英]How do I install Theano and Lasagne in Anaconda (Jupyter)?

我一直在嘗試在 MacOS Sierra (10.12.3) 上的 Anaconda (Jupyter) 中安裝 Lasagne 和 Theano 來使用這個神經網絡: neural-storyteller

但是,當我嘗試在 Jupyter 中導入它們時:

import lasagne
import theano

我收到此錯誤:

ImportError                               Traceback (most recent call last)
<ipython-input-2-7d877a974cd7> in <module>()
----> 1 import lasagne
      2 import theano

//anaconda/lib/python2.7/site-packages/lasagne/__init__.py in <module>()
     11 section 'Install from PyPI' in the installation docs for more details:
     12 http://lasagne.readthedocs.org/en/latest/user/installation.html#install-from-pypi
---> 13 """)
     14 else:
     15     del theano

ImportError: Could not import Theano.

Please make sure you install a recent enough version of Theano.  See
section 'Install from PyPI' in the installation docs for more details:
http://lasagne.readthedocs.org/en/latest/user/installation.html#install-from-pypi

我的猜測是我在不同版本的 python 上安裝了 Theano,因為當我制作一個普通的 python 文件 (.py) 並導入 lasagne 和 theano 時,它們可以工作。 此外,當我查看 User 目錄中的 anaconda 文件夾時,沒有 theano 文件夾,但 miniconda2 文件夾(/Users/Pit/miniconda2/pkgs/theano-0.9.0-py27_0)中有一個。 我可以只使用 .py 文件,但我還需要caffe庫,我只能使用 Anaconda python 來使用它。

有人知道如何安裝適用於 Anaconda (Jupyter) 的正確版本的 theano? 任何幫助將不勝感激

我遇到了同樣的問題。 我認為這是因為 Theano 安裝不正確。 所以這就是我所做的,之后它開始工作:

在 Anaconda 提示中

conda install theano

安裝完成。 它可能會要求一些確認。 然后,

pip install -r https://raw.githubusercontent.com/Lasagne/Lasagne/master/requirements.txt

在那之后,

pip install https://github.com/Lasagne/Lasagne/archive/master.zip

我認為這應該可以解決問題。 就我而言,它在那之后開始工作。 重新啟動內核一次。 有關更多上下文: https : //pypi.org/project/Lasagne/

您應該使用以下命令檢查正在調用哪個 jupyter 和哪個 python:

which python

如果你這樣做:

which jupyter

它們應該在同一目錄中。 例如:

$:/home/spark : which jupyter
~/anaconda2/bin/jupyter
$:/home/spark : which python
~/anaconda2/bin/python

如果它們不相同,那么這可以解釋為什么您不能導入某些庫(因為它們安裝在不同的 python 實例下)。

除非您需要兩者,否則我會刪除 anaconda 或 miniconda 以使事情變得更簡單和更少混亂。

根據我的經驗,Theano 在 Anaconda 和 Jupyter 中運行良好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM