Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: DLL load failed while importing defs: The specified procedure could not be found

I have installed h5py using conda install h5py. However, when I import h5py the above error is given. This is the whole error:

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.

Thanks.

like image 597
vol1n Avatar asked Jan 19 '26 21:01

vol1n


2 Answers

I tried different combinations of h5py and hdf5 versions even the most recent. None of them worked for me. So I did the following and it helped me:

  • uninstalled both the h5py and hdf5 (conda uninstall)
  • pip install h5py (not conda install)

So I left off with only h5py within the conda environment.

Even thought it has some drawbacks as takluyver mentions in his post: 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.

like image 133
Khamyl Avatar answered Jan 21 '26 12:01

Khamyl


This problem is limited to the h5py/hdf5 combination from the conda-forge channel specifically.

Khamyl pointed to the correct open conda-forge issue: https://github.com/conda-forge/h5py-feedstock/issues/103 (it is still open as of the time of this writing).

However, there is no need to uninstall anything or to switch from the conda package manager.

Just downgrade to the latest h5py version available from the pkgs/main channel, e.g.:

conda install h5py=3.6.0 -c pkgs/main

This will downgrade hdf5 to the compatible version from the default channel as well.

like image 32
Gene M Avatar answered Jan 21 '26 10:01

Gene M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!