Missing optional dependency 'tables'. In pandas to_hdf

Question:

  • following code is giving me error.
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:

  • I tried runnig following.
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.

  • It looks like pandas is not giving accurate message for this. Its just saying missing dependency when its actually present.

  • If anyone knows how to resolve this. That will help.

Asked By: Poojan

||

Answers:

  • 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 FilesPython37-64python.exe and installing under c:program filespython37-64libsite-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.
Answered By: Poojan

For conda users:

conda install pytables
Answered By: Matthew

I got it to work by using

conda install snappy
Answered By: Georgios Koutsakis

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
Answered By: Chappy Hickens

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.

Answered By: Gabriel B

using tables 3.6.1 worked for me to resolve the dependency

pip install tables==3.6.1
Answered By: Petter Nordin

I used following command successfully resolved this problem:

pip install --upgrade tables

hope that work for you !

Answered By: yogazining

One cause of this error is an outdated openssl package. User Georgios Koutsakis mentioned that ‘conda install snappy’ will get pd_HDF working; I believe this is because installing this package also initiates an openssl update.

Answered By: Patrick Wickham
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.