通过h5py在hdf5中进行blosc压缩

2024-05-29 03:08:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用h5py在python中创建hdf5文件,我希望使用blosc作为压缩过滤器。我首先通过以下方式从源安装了c-blosc:

wget https://github.com/Blosc/c-blosc/archive/v1.9.1.tar.gz
tar -xvf c-blosc-v1.9.1.tar.gz
cd c-blosc-v1.9.1
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
cmake --build .
cmake --build . --target install

(请注意,我使用的是自制软件,因此我的/usr/local在没有sudo的情况下是可写的)

然后,我通过以下方式从源代码安装了hdf5 v1.10.0:

^{pr2}$

最后,我通过以下方式从源代码安装h5py v2.6.0:

wget https://github.com/h5py/h5py/archive/2.6.0.tar.gz
tar -xvf h5py-2.6.0.tar.gz
cd h5py-2.6.0
python setup.py install
python setup.py install

但是,当我启动python解释器并运行:

import h5py
f = h5py.File('myFile.hdf5','w')
dset = f.create_dataset("myData", (100, 100), compression=32001) 
#32001 is blosc, see: https://www.hdfgroup.org/services/filters.html

我得到错误“ValueError:Unknown compression filter number:32001”。我在安装流程中遗漏了什么?在


Tags: installhttpsbuildgithubcmakecom方式cd
2条回答

import h5py之前

你需要import tables

我发现要使其正常工作,最简单的方法是安装pytables,并在python脚本开始时加载它。之后根本不需要使用pytables,但是加载pytables显然需要注册blosc过滤器。在

相关问题 更多 >

    热门问题