【发布时间】:2021-11-05 14:06:43
【问题描述】:
导入 Tensorflow 会出现此错误
这是我的“代码”:
import tensorflow as tf
我的版本: protoc --version
libprotoc 3.15.8
pip 显示 protobuf
名称:protobuf 版本:3.19.1
张量流 2.6.0
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf
~/miniforge3/envs/userenv/lib/python3.8/site-packages/tensorflow/__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~/miniforge3/envs/userenv/lib/python3.8/site-packages/tensorflow/python/__init__.py in <module>
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
39
---> 40 from tensorflow.python.eager import context
41 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
42
~/miniforge3/envs/userenv/lib/python3.8/site-packages/tensorflow/python/eager/context.py in <module>
30 import six
31
---> 32 from tensorflow.core.framework import function_pb2
33 from tensorflow.core.protobuf import config_pb2
34 from tensorflow.core.protobuf import rewriter_config_pb2
~/miniforge3/envs/userenv/lib/python3.8/site-packages/tensorflow/core/framework/function_pb2.py in <module>
3 # source: tensorflow/core/framework/function.proto
4 """Generated protocol buffer code."""
----> 5 from google.protobuf import descriptor as _descriptor
6 from google.protobuf import message as _message
7 from google.protobuf import reflection as _reflection
~/miniforge3/envs/userenv/lib/python3.8/site-packages/google/protobuf/descriptor.py in <module>
45 import binascii
46 import os
---> 47 from google.protobuf.pyext import _message
48 _USE_C_DESCRIPTORS = True
49
AttributeError: module 'google.protobuf.internal.containers' has no attribute 'MutableMapping'
我正在使用 Jupyter,并且在 Apple M1 上。我使用 Miniforge,我真的不知道下一步该往哪里看。由于原生 M1 芯片,我从 Anaconda 切换到 Miniforge。
【问题讨论】:
-
嗨!您能否按照以下线程的建议再次尝试更新 protobuf 库。 stackoverflow.com/questions/61922334/…
标签: python tensorflow