导入 TensorFlow 时出错。 TypeError:预期字节,找到描述符
Posted
技术标签:
【中文标题】导入 TensorFlow 时出错。 TypeError:预期字节,找到描述符【英文标题】:Error while importing Tensorflow. TypeError: expected bytes, descriptor found 【发布时间】:2020-09-14 02:49:32 【问题描述】:我在 windows 10 中为 CPU 安装了 tensorflow
pip3 install --upgrade tensorflow
它已正确下载并安装,但是当我尝试导入时,它给了我以下错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 32, in <module>
from tensorflow.core.framework import function_pb2
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\core\framework\function_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\core\framework\tensor_shape_pb2.py", line 112, in <module>
'__module__' : 'tensorflow.core.framework.tensor_shape_pb2'
TypeError: expected bytes, Descriptor found
【问题讨论】:
这能回答你的问题吗? TypeError: expected bytes, Descriptor found 我能够解决我的问题,但出现了另一个问题,我找到了新的解决方案,现在我可以使用 tensorflow。谢谢 【参考方案1】:我用
安装了probufpip install protobuf-py3
但是又出现了一个问题
import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 32, in <module>
from tensorflow.core.framework import function_pb2
File "C:\Users\Eloy\anaconda3\lib\site-packages\tensorflow\core\framework\function_pb2.py", line 10, in <module>
from google.protobuf import symbol_database as _symbol_database
File "C:\Users\Eloy\anaconda3\lib\site-packages\google\protobuf\symbol_database.py", line 184, in <module>
_DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
AttributeError: module 'google.protobuf.descriptor_pool' has no attribute 'Default'
这解决了我的新问题 Getting module 'google.protobuf.descriptor_pool' has no attribute 'Default' in my python script
【讨论】:
以上是关于导入 TensorFlow 时出错。 TypeError:预期字节,找到描述符的主要内容,如果未能解决你的问题,请参考以下文章
导入 TensorFlow 时出错。 TypeError:预期字节,找到描述符
导入 tensorflow 时出错,tensorflow 库被编译为使用 AVX 指令,但这些在您的机器上不可用