【问题标题】:blosc compression in hdf5 via h5py通过 h5py 在 hdf5 中进行 blosc 压缩
【发布时间】:2016-09-24 15:49:04
【问题描述】:

我正在使用 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”。我在安装流程中遗漏了什么?

【问题讨论】:

标签: python hdf5 h5py


【解决方案1】:

import h5py之前

你需要import tables

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 这对我将 pytables 和 h5py 安装到新的虚拟环境中不起作用
    • 和我一样,有人有什么有用的建议吗?
    猜你喜欢
    • 1970-01-01
    • 2020-10-27
    • 2010-09-27
    • 1970-01-01
    • 2022-01-09
    • 2016-07-16
    • 2015-12-30
    • 2014-10-28
    • 1970-01-01
    相关资源
    最近更新 更多