RuntimeError:针对API版本a编译的模块,但是这个版本的numpy在ubuntu中是9

时间:2015-12-01 23:24:47

标签: numpy theano

我刚刚安装了theano,但是

import numpy
print numpy.version

这是输出

Theano version 0.7.0.dev-30cc6380863b08a3a90ecbe083ddfb629a56161d
theano is installed in /home/sizhexi/theano/Theano/theano
NumPy version 1.8.2
NumPy is installed in /usr/lib/python2.7/dist-packages/numpy
Python version 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
nose version 1.3.1
RuntimeError: module compiled against API version a but this version of numpy is 9
terminate called after throwing an instance of 'std::runtime_error'
  what():  numpy failed to initialize
Aborted (core dumped)

如何解决?

1 个答案:

答案 0 :(得分:1)

python中的包管理有时很棘手。为了避免这些问题,我建议使用Anaconda,这是一个很好的python包和环境管理器(download here30 minutes guide)。

按照官方说明安装Anaconda并选择将Anaconda添加到$ PATH的默认值,并将Anaconda作为默认的python解释器。然后打开终端并使用以下命令:

  • conda install pip six nose numpy scipy
  • pip install theano

然后尝试使用anaconda运行脚本。