CodeLee24 2021-04-08 10:20 采纳率: 75%
浏览 243
已结题

cannot import name 'resource_handle_pb2'这个要怎么样解决呢?

D:\Anaconda\envs\tensorflow\python.exe D:/desk/bert-master/bert-master/run_pretraining.py
Traceback (most recent call last):
  File "D:/desk/bert-master/bert-master/run_pretraining.py", line 22, in <module>
    import modeling
  File "D:\desk\bert-master\bert-master\modeling.py", line 28, in <module>
    import tensorflow as tf
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 16, in <module>
    from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
  File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\core\framework\node_def_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 "D:\Anaconda\envs\tensorflow\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 "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 15, in <module>
    from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
ImportError: cannot import name 'resource_handle_pb2

from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
from tensorflow.core.framework import types_pb2 as tensorflow_dot_core_dot_framework_dot_types__pb2

'

  • 写回答

1条回答 默认 最新

  • Brentbin 2021-04-08 18:23
    关注

    This is because of protobuf version conflict: for me i had python-protobuf v2.6.1 installed from apt-get package manager and while installing tensorflow it installed protobuf v3.3.0 from pip manager

    To check version of protobuf from aptitude

    aptitude versions python-protobuf
    

    To check version of protobuf from pip

    pip show protobuf
    

    so i uninstalled both:

    sudo pip uninstall protobuf
    sudo apt-get remove python-protobuf
    

    Reinstalled using pip and it solved the issue!!!

    sudo pip install protobuf
    

    Hope this helps..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月3日
  • 已采纳回答 8月26日

悬赏问题

  • ¥15 WPF如何用Chart绘画出Y轴的左边数据
  • ¥15 pycharm无法查看内置代码
  • ¥15 跑hls xfopencv的例程standalone_hls_axi_example出的错误,csim没问题,c synthesis出的错误
  • ¥15 sqlserver update语句逐行生效
  • ¥15 mssql2000游标循环次数对不上
  • ¥20 Windows10系统命令行调用
  • ¥15 php环境如何实现国密SM2相关功能
  • ¥15 关于#单片机#的问题:K210 例程里面提示我iomem.h: No such file or directory
  • ¥15 LSPI算法的大问题
  • ¥15 java导出word 动态填充数据