【问题标题】:RuntimeError: module compiled against API version a but this version of numpy is 9 in ubuntuRuntimeError:针对 API 版本 a 编译的模块,但这个版本的 numpy 在 ubuntu 中是 9
【发布时间】:2023-03-20 00:24:01
【问题描述】:

我刚刚安装了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)

如何解决?

【问题讨论】:

    标签: numpy theano


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2016-02-24
      • 2021-06-29
      • 2018-06-11
      • 2016-09-27
      • 2018-10-13
      • 2018-09-20
      • 2014-01-26
      • 1970-01-01
      相关资源
      最近更新 更多