Poojan
Poojan

Reputation: 3519

Missing optional dependency 'tables'. In pandas to_hdf

import pandas as pd
df = pd.DataFrame({'a' : [1,2,3]})
df.to_hdf('temp.h5', key='df', mode='w')

Some version info.

  • python 3.7.4
  • pandas 0.25.2
  • windows10

PS: You can reproduce this in repl https://repl.it/.

Update:

import tables

and got this error:

ImportError: Could not load any of ['hdf5.dll', 'hdf5dll.dll'], please ensure that it can be found in the system path.

Upvotes: 44

Views: 61737

Answers (9)

leeprevost
leeprevost

Reputation: 444

Bizarrely, I found that the pandas error has nothing to do with pytables which was the last error produced. Up higher in the stack trace, I noticed an error about Callables not being imported (typing support).

This fixed me:

 pip install --upgrade typing_extensions

Upvotes: 0

David Cohen
David Cohen

Reputation: 11

Using MacOS Ventura on Apple M2 processor the above was not working for me. What finally was working for me:

env HDF5_DIR=/opt/homebrew/opt/hdf5 python3 -m pip install tables

Where /opt/homebrew/opt/hdf5 is the hdf5 installation location

Upvotes: 0

yogazining
yogazining

Reputation: 169

I used following command successfully resolved this problem:

pip install --upgrade tables

hope that work for you !

Upvotes: 3

Chappy Hickens
Chappy Hickens

Reputation: 445

The above solutions did not work for me. Perhaps because I built the individual environment using the conda-forge channel, I had success with this:

conda install -c conda-forge pytables

Upvotes: 2

Petter Nordin
Petter Nordin

Reputation: 41

using tables 3.6.1 worked for me to resolve the dependency

pip install tables==3.6.1

Upvotes: 4

Gabriel B
Gabriel B

Reputation: 1

This problem has appeared for me when refreshing an existing conda virtal env using pip install -U -r requirements.txt. I resolved the issue as follows:

  1. conda env remove -n <env> # remove your virtual env.
  2. conda create -n <env> python==3.8 # create your virtual env again.
  3. pip install -U -r requirements.txt

It's quite tedius to maintain a mix of conda and pip packages, so I just use the latter.

Upvotes: 0

Georgios Koutsakis
Georgios Koutsakis

Reputation: 61

I got it to work by using

conda install snappy

Upvotes: 6

Matthew
Matthew

Reputation: 11387

For conda users:

conda install pytables

Upvotes: 36

Poojan
Poojan

Reputation: 3519

  • The issue was with tables.
  • When i was installing tables using pip into local user directory using following command it's not working.
pip install --user tables
  • Running import tables will result in this error.

    ImportError: Could not load any of ['hdf5.dll', 'hdf5dll.dll'], please ensure that it can be found in the system path

  • The solution that worked for me is to uninstall tables. And install it into python's directory. (or where your python is installed). without --user option. You may require admin/root access for this depending upon location of your python.

  • For me my python path was C:\Program Files\Python37-64\python.exe and installing under c:\program files\python37-64\lib\site-packages\ worked for me.
  • Hope this helps. I don't know why installing in user directory is not working for tables. If anyone can find the reason for that please post here.

Upvotes: 31

Related Questions