python可视化hdf5文件的操作
作者:工科pai 时间:2022-11-16 16:35:48
对于一些复杂的hdf5文件,通过可视化的方法可以比较容易的了解文件的内部结构,下面介绍基于python的一个hdf5文件的安装使用方法
1 安装vitables工具包
命令 pip install vitables
2 安装完成后在终端中使用命令
vitables 文件名.hdf5
最终实现hdf5文件的可视化,方便直观就像一层层打开文件夹一样
补充:python对于HDF5的操作
看代码吧~
import h5py #导入工具包
import numpy as np
#HDF5的写入:
imgData = np.zeros((30,3,128,256))
f = h5py.File('HDF5_FILE.h5','w') #创建一个h5文件,文件指针是f
f['data'] = imgData #将数据写入文件的主键data下面
f['labels'] = range(100) #将数据写入文件的主键labels下面
f.close() #关闭文件
#HDF5的读取:
f = h5py.File('HDF5_FILE.h5','r') #打开h5文件
f.keys() #可以查看所有的主键 :在这里是:【data】,[label]
a = f['data'][:] #取出主键为data的所有的键值
f.close()
补充:关于python环境中hdf5报错问题的几种解决办法(亲测)
一、报错内容如下:
Warning! HDF5 library version mismatched error
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as ‘LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable ‘HDF5_DISABLE_VERSION_CHECK' to a value of ‘1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.4, library is 1.10.5
二、几种解决办法
首先,这个问题是有可能是hdf5库不匹配的问题,也有可能是一个类似warning的东西,下面我会详细的说一下。
第一种解决办法:
卸载hdf5,然后重新安装。
终端执行的代码如下:
conda uninstall hdf5
conda install hdf5
网上有好多朋友用这个方法有用, 本人亲测:方法对我无用。
第二种解决办法:
检查一下设置的路径:LD_LIBRARY_PATH
本人亲测:由于我使用的系统是win10,但是LD_LIBRARY_PATH这个路径我找了 好半天也找不到,后来搜索一下发现时Linux的,所以这个方法我没有使用。
第三种解决办法:
将HDF5_DISABLE_VERSION_CHECK设置为更高等级,忽略警告。
在import tensorflow之前,在代码中添加如下代码:
import os;
os.environ[‘HDF5_DISABLE_VERSION_CHECK'] = ‘2'
本人亲测:此方法着实有用!
来源:https://blog.csdn.net/weixin_45653050/article/details/111410478
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
django+xadmin+djcelery实现后台管理定时任务
![](https://img.aspxhome.com/file/2023/5/97325_0s.png)
PyQt5 QLineEdit输入的子网字符串校验QRegExp实现
![](https://img.aspxhome.com/file/2023/7/121437_0s.png)
ThinkPHP中pathinfo的访问模式、路径访问模式及URL重写总结
CSS系统默认颜色
Python列表推导式与生成器用法分析
PHP实现获取客户端IP并获取IP信息
Python实现扫描局域网活动ip(扫描在线电脑)
用私有属性来拯救IE7缩放图片的失真
![](https://img.aspxhome.com/file/UploadPic/20093/3/feed-22s.gif)
教你如何利用SQL Server保护数据
在ASP.NET 2.0中操作数据之三十一:使用DataList来一行显示多条记录
![](https://img.aspxhome.com/file/2023/1/126201_0s.png)
基于python requests selenium爬取excel vba过程解析
JS原生轮播图的简单实现(推荐)
关于Math.PI、前自增和后自增
简化ADO数据库操作的控件(带分页功能)
61条面向对象设计的经验原则
pandas创建DataFrame的方式小结
![](https://img.aspxhome.com/file/2023/2/86632_0s.png)
Python实现优先级队列结构的方法详解
基于PyQt5制作一个数据图表生成器
![](https://img.aspxhome.com/file/2023/1/86551_0s.png)
浅谈python opencv对图像颜色通道进行加减操作溢出
![](https://img.aspxhome.com/file/2023/3/99473_0s.jpg)
python 计算t分布的双侧置信区间
![](https://img.aspxhome.com/file/2023/9/61489_0s.jpg)