【问题标题】:TensorFlow for Mac: error importing tensorflowTensorFlow for Mac:导入 tensorflow 时出错
【发布时间】:2017-05-05 22:00:18
【问题描述】:

我正在尝试在我的 Mac 上使用 TensorFlow。

我在终端并按照 Tensorflow 安装页面上的所有说明操作,直到“运行一个简短的测试程序”

我正在尝试写

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 "/Users/robilin/Library/Python/2.7/lib/python/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Users/robilin/Library/Python/2.7/lib/python/site-packages/tensorflow/python/__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/robilin/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/robilin/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/robilin/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/robilin/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import


Failed to load the native TensorFlow runtime.

任何帮助都会很棒!

【问题讨论】:

  • 请格式化您的异常以便其他人可以阅读

标签: python macos tensorflow machine-learning importerror


【解决方案1】:

您的 numpy 版本似乎不兼容。

你需要升级 numpy

【讨论】:

    【解决方案2】:

    你可以跑

    pip install --upgrade numpy
    

    将 numpy 升级到最新版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-16
      • 2017-09-08
      • 1970-01-01
      • 2017-08-30
      • 1970-01-01
      • 2016-08-28
      相关资源
      最近更新 更多