报错:AttributeError: ‘str‘ object has no attribute ‘decode‘

original_keras_version = f.attrs[‘keras_version’].decode(‘utf8’) AttributeError: ‘str’ object has no attribute ‘decode’

1、问题描述

original_keras_version = f.attrs['keras_version'].decode('utf8') 
AttributeError: 'str' object has no attribute 'decode'

2、原因分析

在安装tensorflow时,默认安装h5py为3.1.0,而报错是因为你安装的TF不支持过高版本的h5py。
在这里插入图片描述

3、解决方案

  1. 卸载h5py3.1.0版本,安装h5py2.10.0版本
pip install h5py==2.10.0
  1. 重新运行

无报错,运行成功!

猜你喜欢

转载自blog.csdn.net/s1_0_2_4/article/details/135894436