Conda环境导入h5/h5py报错:undefined symbol: H5Pget_fapl_direct
h5py导入报错:undefined symbol: H5Pget_fapl_direct
安装操作
先后执行了以下命令安装h5py:
conda install h5py pip install h5py
当前环境已安装的相关包
h5 0.5.2 pypi_0 pypi h5py 3.7.0 nompi_py310h06dffec_100 conda-forge
导入报错信息
Traceback (most recent call last): File "/vol/ideadata/oc69ubiw/Explainer_GNN/patho-quant-explainer/core/generate_cell_graphs.py", line 14, in <module> from histocartography.preprocessing import ( File "/vol/ideadata/oc69ubiw/conda/pathoexplainer/lib/python3.10/site-packages/histocartography/__init__.py", line 1, in <module> from .pipeline import PipelineRunner, BatchPipelineRunner File "/vol/ideadata/oc69ubiw/conda/pathoexplainer/lib/python3.10/site-packages/histocartography/pipeline.py", line 12, in <module> import h5py File "/vol/ideadata/oc69ubiw/conda/pathoexplainer/lib/python3.10/site-packages/h5py/__init__.py", line 33, in <module> from . import version File "/vol/ideadata/oc69ubiw/conda/pathoexplainer/lib/python3.10/site-packages/h5py/version.py", line 15, in <module> from . import h5 as _h5 File "h5py/h5.pyx", line 1, in init h5py.h5 ImportError: /vol/ideadata/oc69ubiw/conda/pathoexplainer/lib/python3.10/site-packages/h5py/defs.cpython-310-x86_64-linux-gnu.so: undefined symbol: H5Pget_fapl_direct
解决办法
这个错误是conda和pip混装导致的包冲突,或者h5py依赖的HDF5库版本不兼容,按以下步骤处理:
- 彻底卸载现有相关包:
pip uninstall -y h5 h5py conda uninstall -y h5py - 清理conda缓存,避免残留问题:
conda clean -a - 只用conda重新安装h5py,保证依赖库版本匹配:
conda install -c conda-forge h5py - 验证安装是否成功:
python -c "import h5py; print(h5py.__version__)"
内容的提问来源于stack exchange,提问作者Starry Night
相关产品推荐
相关产品推荐

