首页 > 解决方案 > 从源代码构建后的Tensorflow导入错误

问题描述

我从这个版本https://github.com/tensorflow/tensorflow/releases/tag/v1.13.0-rc0的源代码构建了具有 GPU 支持的 tensorflow,并且一切正常,但是当我在 python 中导入 tensorflow 时,我得到了错误

>>> import tensorflow
ImportError: No module named _multiarray_umath
ImportError: No module named _multiarray_umath
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 "tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "tensorflow/python/__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "tensorflow/core/framework/graph_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
ImportError: No module named protobuf

我确实安装了 protobuf。我也将 ubuntu 16.04 与 CUDA 10 一起使用。有人知道这里有什么问题吗?

标签: pythontensorflow

解决方案


如果有人感兴趣,我在这里找到了解决方案https://github.com/tensorflow/tensorflow/issues/6341

但基本上它只是

pip uninstall protobuf
pip uninstall google
pip install google
pip install protobuf

推荐阅读