python - 通过 h5py 在 hdf5 中进行 blosc 压缩

标签 python hdf5 h5py

我正在使用 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:

wget http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.0/src/hdf5-1.10.0.tar.gz
tar -xvf hdf5-1.10.0.tar.gz
cd hdf5-1.10.0
./configure --enable-static=yes --enable-shared=yes --prefix=/usr/local/hdf5
make && make install

最后,我通过以下方式从源代码安装了 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:未知压缩过滤器编号:32001”。我在安装流中遗漏了什么?

最佳答案

我发现最简单的方法是安装 pytables并在 python 脚本的开头加载它。之后你根本不需要使用 pytables,但加载它显然会调用注册 blosc 过滤器的东西。

关于python - 通过 h5py 在 hdf5 中进行 blosc 压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37464262/

相关文章:

python - OSError 无法创建文件 - 参数无效

Python-如何将时间序列存储到数据集中

python - 使用 Beautifulsoup 4 和 Python 2.7 解析 Web 表单

python - 导入错误 : libOpenGL. so.0:无法打开共享对象文件:没有这样的文件或目录

python - 使用不同大小的 h5py 数组保存

python - 在pyspark中加载大于内存的hdf5文件

python-2.7 - 删除 h5py 数据集的项目,但文件大小加倍

python - 在 for 循环中将数据集写入 .hdf5 文件时出现问题

python - 将具有重复键的 Pandas DataFrame 转换为字典

python - Web2py 每个 session 导入一次