导入tensorflow时出现numpy版本错误

问题描述 投票:3回答:1

我已经为tensorflow执行了pip install

在python命令行环境下,当我尝试

import tensorflow as tf

我遇到了以下错误:

RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

我用numpy检查了我的print numpy.__version__版本。它显示了"1.8.2"。那么,我现在该怎么办?谢谢!

python python-2.7 numpy runtime-error tensorflow
1个回答
2
投票

从错误中,看起来你正在从usr/local/bin运行python 2.7。你的numpy版本和tensorflow安装之间存在不匹配问题。我建议您安装anaconda,因为它将确保安装与tensorflow版本兼容的正确版本的numpy

一旦你有了anaconda,那么:

conda install -c conda-forge tensorflow
© www.soinside.com 2019 - 2024. All rights reserved.