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

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日

悬赏问题

  • ¥50 用预估矫正法,分数阶微分方程组传染病的最优控制代码怎么写
  • ¥15 画个数据流程图,手画也行
  • ¥60 AS自带模拟器AVD Root 和 Xposed安装
  • ¥15 Esp32的microPython设备中main.py文件无法开机自启动
  • ¥30 哪位搞Android的编程师可以帮我远程一下,悬赏30元
  • ¥15 solidity部署上合约,可以mint,也继承接口了,在区块链也不显示代币名字
  • ¥15 讨论 博士论文交互项怎么讨论?
  • ¥50 在集成BiLSTM和GCN模型时遇到了问题
  • ¥33 集成BiLSTM模型和GCN模型时,前模型的输出不匹配后模型的输入
  • ¥15 关于液体厚度提取,和铺展轨迹数据化处理