我已经尝试了GitHub和Stack Overflow论坛中提到的一些解决方案,例如RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb,但是尝试了不同的解决方案后,我仍然无法解决此问题。问题是,当我导入keras或tensorflow时,会出现保存错误:
Using TensorFlow backend.
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
ImportError: numpy.core.multiarray failed to import
ImportError: numpy.core.umath failed to import
ImportError: numpy.core.umath failed to import
2019-04-22 20:04:47.663759: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr
Abort trap: 6
无论我在终端Jupyter Notebook上尝试如何,在多次更改tensorflow和numpy的版本后,它仍然会输出相同的错误。
MacOS 10.13.6 High Sierra Python 3.6.8
目前,我在Macintosh磁盘上安装了Python 3.6.0,在Anaconda上安装了Python 3.6.8(以某种方式无法清理Anaconda的某些部分)。 Tensorflow应为1.13.1。目前,我的Numpy版本是1.13.3。我尝试了1.12和1.14的变体,但似乎无法正常工作。至于Keras,它是2.2.4版本。
如果我使用Python 3.6.0,则错误为:
Using TensorFlow backend.
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ImportError: numpy.core.multiarray failed to import
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 960, in _find_and_load
SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/protobuf/__init__.py", line 37, in <module>
__import__('pkg_resources').declare_namespace(__name__)
AttributeError: module 'pkg_resources' has no attribute 'declare_namespace'