我已经使用 conda install h5py
安装了 h5py。但是,当我 import h5py
时,出现了上述错误。这是整个错误:
Traceback (most recent call last):
File "training.py", line 12, in <module>
import h5py
File "C:\Users\colin\anaconda3\envs\py38\lib\site-packages\h5py\__init__.py", line 33, in <module>
from . import version
File "C:\Users\colin\anaconda3\envs\py38\lib\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: DLL load failed while importing defs: The specified procedure could not be found.
谢谢。
最佳答案
我尝试了 h5py
和 hdf5
版本的不同组合,甚至是最新版本。他们都不为我工作。所以我做了以下事情,它对我有帮助:
- 卸载了
h5py
和hdf5
(conda uninstall
) - pip install
h5py
(不是conda install
)
所以我在 conda 环境中只使用了 h5py
。
即使认为它有一些缺点,正如 takluyver 在他的帖子中提到的:https://github.com/conda-forge/h5py-feedstock/issues/103#issuecomment-1017537370
The wheel package (what you get with pip) bundles libhdf5 into the wheel, so it should never 🤞 have a mismatch between the HDF5 used to build h5py and the HDF5 it finds at runtime. That approach has its downsides, though - e.g. the read-only S3 driver is enabled in conda-forge, but not in pip, because that would mean bundling more libraries.
关于python - 导入错误: DLL load failed while importing defs: The specified procedure could not be found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68296054/