pandas: Can't import h5py with pandas

Here’s what I’m currently doing:

import h5py as h5
import pandas as pd

def init_stores():
    """Check if h5 exists, create one if it doesn't"""
    for store_path in store_paths:
        try:
            with h5.File(store_path, 'r'):
                pass
        except OSError:
            with h5.File(store_path, 'w'):
                logger.info("Created h5 file: {}".format(store_path))
                pass

def update_hdf():
    with pd.HDFStore(store_path) as store:
        print("In the update function")
        exit()

And I’m getting this error:

Traceback (most recent call last):
  File "C:\venv\lib\site-packages\pandas\io\pytables.py", line 445, in __init__
    import tables  # noqa
  File "C:\venv\lib\site-packages\tables\__init__.py", line 90, in <module>
    from .utilsextension import (
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/.../hdf_stuff.py", line 93, in <module>
    main()
  File "C:/.../hdf_stuff.py", line 89, in main
    update_hdf()
  File "C:/.../hdf_stuff.py", line 39, in update_hdf
    with pd.HDFStore(store_path) as store:
  File "C:\venv\lib\site-packages\pandas\io\pytables.py", line 448, in __init__
    'importing'.format(ex=str(ex)))
ImportError: HDFStore requires PyTables, "DLL load failed: The specified procedure could not be found." problem importing

If I comment out the h5py import, it works.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

I managed to get pytables and h5py working together on windows10 by downgrading h5py to version 2.7.0. pip uninstall h5py pip install h5py=2.7.0

I suddenly started facing this issue. I did an uninstall followed by an install, and it fix the problem. pip uninstall h5py pip install h5py