python ImportError:无法从'google.protobuf.pyext'导入名称'_message'(c:\programdata\anaconda 3\lib\site-packages\google\protobuf\pyext\__init__.py)

amrnrhlw  于 2023-06-04  发布在  Python
关注(0)|答案(5)|浏览(787)

我正在尝试这个命令(我不知道它做什么!我只遵循一个教程):

tensorboard --logdir=/tmp/tensorflow/rnn_words

并得到这个结果:

Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\tensorboard.exe\__main__.py", line 5, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\tensorboard\main.py", line 45, in <module>
    from tensorboard import default
  File "c:\programdata\anaconda3\lib\site-packages\tensorboard\default.py", line 34, in <module>
    import tensorflow as tf
  File "c:\programdata\anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "c:\programdata\anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
  File "c:\programdata\anaconda3\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext' (c:\programdata\anaconda3\lib\site-packages\google\protobuf\pyext\__init__.py)

上面的命令有什么作用?为什么我会收到此错误消息?

C:\Windows\system32>python --version
Python 3.7.1

C:\Windows\system32>pip install protobuf
Requirement already satisfied: protobuf in c:\programdata\anaconda3\lib\site-packages (3.6.1)
Requirement already satisfied: six>=1.9 in c:\programdata\anaconda3\lib\site-packages (from protobuf) (1.12.0)
Requirement already satisfied: setuptools in c:\programdata\anaconda3\lib\site-packages (from protobuf) (40.6.3)
30byixjq

30byixjq1#

请使用以下命令升级protobuf

pip3 install --upgrade --force-reinstall protobuf==4.32.2
jvidinwx

jvidinwx2#

我把protobuf pip install protobuf==3.19.6降级了

eoxn13cs

eoxn13cs3#

根据tensorboard issue #1556的分辨率,您还可以通过升级到tensorboard==1.13.0(或更高版本)来解决问题。
IMO,这是最干净的解决方案。

t9aqgxwy

t9aqgxwy4#

如果你是mac,请尝试pip install --upgrade --force-reinstall protobuf

hc2pp10m

hc2pp10m5#

在Python 3.9中使用pip install protobuf==3.14.0
您可以使用以下内容进行测试:

# python
Python 3.9.13 (main, Aug  2 2022, 11:20:39)
>>> from google.protobuf.pyext.cpp_message import GeneratedProtocolMessageType

相关问题