ImportError: numpy.core.multiarray failed to import解決辦法
阿新 • • 發佈:2019-01-01
描述問題
ImportError: numpy.core.multiarray failed to import
>>> import tensorflow as tf RuntimeError: module compiled against API version 0xa but this version of numpy is 0x7 RuntimeError: module compiled against API version 0xa but this version of numpy is 0x7 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module> from tensorflow.python import * File "/usr/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "/usr/lib/python2.7/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. See https://www.tensorflow.org/install/install_sources#common_installation_problems for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
解決辦法
- 檢視 numpy安裝位置
>>> import numpy
>>> print numpy.__path__
['/usr/lib64/python2.7/site-packages/numpy']
- 刪除目錄
# rm -fr /usr/lib64/python2.7/site-packages/numpy
- 再重新安裝
# pip install numpy --upgrade --force
- 問題解決
>>> import tensorflow as tf >>>