Linux 平台使用无法通过R语言的 rhdf5::H5Fopen
和 hdf5r::H5File$new
打开H5格式文件,抛出异常“HDF5. File accessibility. Unable to open file.” 参考 https://github.com/GreenleafLab/ArchR/issues/248?spm=a2c6h.13046898.0.0.5ae16ffa2qPYS6 完成Debug 过程记录:
1、异常 INFO
- 1.
rhdf5::H5Fopen
函数异常 error:data.h5 <- H5Fopen(name = "exp_matrix.hdf5") Error in H5Fopen(name = "exp_matrix.hdf5", : HDF5. File accessibility. Unable to open file.
2.
hdf5r::H5File$new
函数异常 error:hdf5r::H5File$new("exp_matrix.hdf5", mode="r") Error in H5File.open(filename, mode, file_create_pl, file_access_pl) : HDF5-API Errors: error #000: H5F.c in H5Fopen(): line 620: unable to open file class: HDF5 major: File accessibility minor: Unable to open file error #001: H5VLcallback.c in H5VL_file_open(): line 3501: failed to iterate over available VOL connector plugins class: HDF5 major: Virtual Object Layer minor: Iteration failed error #002: H5PLpath.c in H5PL__path_table_iterate(): line 578: can't iterate over plugins in plugin path '(null)' class: HDF5 major: Plugin for dynamically loaded library minor: Iteration failed error #003: H5PLpath.c in H5PL__path_table_iterate_process_path(): line 620: can't open directory: ~/local/Minconda/envs/scRNA/lib/hdf5/plugin class: HDF5 major: Plugin for dynamically loaded library minor: Can't open directory or file error #004: H5VLcallback.c in H5VL__file_open(): line 3351: open faile
2、处理策略
引发该异常的原因是系统默认打开了使用HDF5库时启用文件锁定。解决方案:编辑Linux 用户的配置文件(.bashrc)添加以下两句环境变量:
export HDF5_USE_FILE_LOCKING="FALSE"
export RHDF5_USE_FILE_LOCKING="FALSE"
然后执行source ~/.bashrc
,就可以解决Linux环境下无法读取h5文件的错误了。