Tensorflow安装后运行pycharm结果protobuf版本一会高一会儿低

pycharm安装好tensorflow后运行代码报错如下

img

然后上网搜索是protobuf版本过高就pip install protobuf==3.19.0下载低版本
然后又报错

img


又搜说是版本过低,我就这俩来回卡
代码没报错,运行后报错

如果你是初学,建议换pytorch吧,tensoflow版本匹配,小版本之间的api变动蛋疼的要死

  • 这篇文章:tensorflow安装protobuf 也许能够解决你的问题,你可以看下
  • 除此之外, 这篇博客: tensorflow 与protobuf版本对应问题中的 卸载 protobuf 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • Note! 因为之前第一次安装protobuf 采用的是覆盖安装,所以将Ubuntu自带的protobuf覆盖掉了, 所以我选择直接卸载掉最新的,重新安装,没有采用兼容安装的方式

    删除方式, 进入到下载的protobuf 路径里, 采用 make uninstall 方式

    siz@ubuntu:~/soft$ cd protobuf-3.15.8/
    siz@ubuntu:~/soft/protobuf-3.15.8$ sudo make uninstall
    [sudo] password for siz: 
    Making uninstall in .
    make[1]: Entering directory '/home/siz/soft/protobuf-3.15.8'
     ( cd '/usr/local/lib/pkgconfig' && rm -f protobuf.pc protobuf-lite.pc )
    make[1]: Leaving directory '/home/siz/soft/protobuf-3.15.8'
    Making uninstall in src
    make[1]: Entering directory '/home/siz/soft/protobuf-3.15.8/src'
     ( cd '/usr/local/bin' && rm -f protoc )
     /bin/bash ../libtool   --mode=uninstall rm -f '/usr/local/lib/libprotobuf-lite.la'
    libtool: uninstall: rm -f /usr/local/lib/libprotobuf-lite.la /usr/local/lib/libprotobuf-lite.a
     /bin/bash ../libtool   --mode=uninstall rm -f '/usr/local/lib/libprotobuf.la'
    libtool: uninstall: rm -f /usr/local/lib/libprotobuf.la /usr/local/lib/libprotobuf.a
     /bin/bash ../libtool   --mode=uninstall rm -f '/usr/local/lib/libprotoc.la'
    libtool: uninstall: rm -f /usr/local/lib/libprotoc.la /usr/local/lib/libprotoc.a
     ( cd '/usr/local/include' && rm -f google/protobuf/descriptor.proto google/protobuf/any.proto google/protobuf/api.proto google/protobuf/duration.proto google/protobuf/empty.proto google/protobuf/field_mask.proto google/protobuf/source_context.proto google/protobuf/struct.proto google/protobuf/timestamp.proto google/protobuf/type.proto google/protobuf/wrappers.proto google/protobuf/compiler/plugin.proto )
     ( cd '/usr/local/include' && rm -f google/protobuf/stubs/callback.h google/protobuf/stubs/bytestream.h google/protobuf/stubs/casts.h google/protobuf/stubs/common.h google/protobuf/stubs/hash.h google/protobuf/stubs/logging.h google/protobuf/stubs/macros.h google/protobuf/stubs/map_util.h google/protobuf/stubs/mutex.h google/protobuf/stubs/once.h google/protobuf/stubs/platform_macros.h google/protobuf/stubs/port.h google/protobuf/stubs/status.h google/protobuf/stubs/stl_util.h google/protobuf/stubs/stringpiece.h google/protobuf/stubs/strutil.h google/protobuf/stubs/template_util.h google/protobuf/any.pb.h google/protobuf/api.pb.h google/protobuf/any.h google/protobuf/arena.h google/protobuf/arena_impl.h google/protobuf/arenastring.h google/protobuf/descriptor_database.h google/protobuf/descriptor.h google/protobuf/descriptor.pb.h google/protobuf/duration.pb.h google/protobuf/dynamic_message.h google/protobuf/empty.pb.h google/protobuf/extension_set.h google/protobuf/extension_set_inl.h google/protobuf/field_mask.pb.h google/protobuf/generated_enum_reflection.h google/protobuf/generated_enum_util.h google/protobuf/generated_message_reflection.h google/protobuf/generated_message_table_driven.h google/protobuf/generated_message_util.h google/protobuf/has_bits.h google/protobuf/implicit_weak_message.h google/protobuf/io/io_win32.h google/protobuf/map_entry.h google/protobuf/map_entry_lite.h google/protobuf/map_field.h google/protobuf/map_field_inl.h google/protobuf/map_field_lite.h google/protobuf/map.h google/protobuf/map_type_handler.h google/protobuf/message.h google/protobuf/message_lite.h google/protobuf/metadata.h google/protobuf/metadata_lite.h google/protobuf/parse_context.h google/protobuf/port.h google/protobuf/port_def.inc google/protobuf/port_undef.inc google/protobuf/reflection.h google/protobuf/reflection_ops.h google/protobuf/repeated_field.h google/protobuf/service.h google/protobuf/source_context.pb.h google/protobuf/struct.pb.h google/protobuf/text_format.h google/protobuf/timestamp.pb.h google/protobuf/type.pb.h google/protobuf/unknown_field_set.h google/protobuf/wire_format.h google/protobuf/wire_format_lite.h google/protobuf/wrappers.pb.h google/protobuf/io/coded_stream.h google/protobuf/io/gzip_stream.h google/protobuf/io/printer.h google/protobuf/io/strtod.h google/protobuf/io/tokenizer.h google/protobuf/io/zero_copy_stream.h google/protobuf/io/zero_copy_stream_impl.h google/protobuf/io/zero_copy_stream_impl_lite.h google/protobuf/compiler/code_generator.h google/protobuf/compiler/command_line_interface.h google/protobuf/compiler/importer.h google/protobuf/compiler/parser.h google/protobuf/compiler/plugin.h google/protobuf/compiler/plugin.pb.h google/protobuf/compiler/cpp/cpp_generator.h google/protobuf/compiler/csharp/csharp_generator.h google/protobuf/compiler/csharp/csharp_names.h google/protobuf/compiler/java/java_generator.h google/protobuf/compiler/java/java_names.h google/protobuf/compiler/js/js_generator.h google/protobuf/compiler/js/well_known_types_embed.h google/protobuf/compiler/objectivec/objectivec_generator.h google/protobuf/compiler/objectivec/objectivec_helpers.h google/protobuf/compiler/php/php_generator.h google/protobuf/compiler/python/python_generator.h google/protobuf/compiler/ruby/ruby_generator.h google/protobuf/util/type_resolver.h google/protobuf/util/delimited_message_util.h google/protobuf/util/field_comparator.h google/protobuf/util/field_mask_util.h google/protobuf/util/json_util.h google/protobuf/util/time_util.h google/protobuf/util/type_resolver_util.h google/protobuf/util/message_differencer.h )
    make[1]: Leaving directory '/home/siz/soft/protobuf-3.15.8/src'
    siz@ubuntu:~/soft/protobuf-3.15.8$ which protoc
    siz@ubuntu:~/soft/protobuf-3.15.8$ 
    
  • 您还可以看一下 刘旭东老师的LabVIEW工业深度学习TensorFlow【基础篇】课程中的 放置Protoc.exe C盘下运行安装protobuf==3.6.0小节, 巩固相关知识点