38
  • 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.

titusjan
  • 5,376
  • 2
  • 24
  • 43
Poojan
  • 3,366
  • 2
  • 17
  • 33
  • What is your operating system, python executable location, and what IDE are you using (PyCharm, VSCode, etc?) Also, what version of Pandas and Python are you using? – James Oct 23 '19 at 13:48
  • On repl.it your code runs fine once you add tables==3.6.0 as a package in the repl. – Davide Fiocco Oct 23 '19 at 13:59
  • @DavideFiocco it looks like right now its working on relt.it. I am not on my home work station right now. Once i will get back to home i will check and update the question. – Poojan Oct 23 '19 at 14:13
  • @James version info are mentioned in question. I am using jupyter notebook to run the code. – Poojan Oct 23 '19 at 14:14
  • on my Linux machine the package seems to be called `pytables`. Can you check if installing `pytables` resolves your issue? Your code snippet works fine with `pytables` installed. – Sergey Bushmanov Oct 24 '19 at 04:13
  • What package manager do you use? Can you try reinstalling the desired package with pip or conda and see if the import is successful? – Sergey Bushmanov Oct 24 '19 at 04:32
  • @SergeyBushmanov I am using pip to install this. Also its still failing after reinstallation of package. – Poojan Oct 24 '19 at 17:03

8 Answers8

34

For conda users:

conda install pytables
Matthew
  • 10,361
  • 5
  • 42
  • 54
  • Perfect. Installs both tables and numexpr into site-packages. – Peter Mar 28 '20 at 08:12
  • For me, the same 'missing tables' error was raised from `miniconda3\lib\site-packages\pandas\io\pytables.py` in `__init__` when executing `tables = import_optional_dependency("tables")` which seems to indicate `pytables` module was already installed. Still your solution solved the problem. Can't understand. – mins Jan 23 '21 at 12:06
  • 1
    I had the same issue as @mins but `conda `wouldn't resolve. `pip install tables` did the trick – pedrosaurio May 27 '22 at 12:47
27
  • 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.
Poojan
  • 3,366
  • 2
  • 17
  • 33
5

I got it to work by using

conda install snappy
3

using tables 3.6.1 worked for me to resolve the dependency

pip install tables==3.6.1
2

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
vvvvv
  • 25,404
  • 19
  • 49
  • 81
Chappy Hickens
  • 397
  • 2
  • 5
2

I used following command successfully resolved this problem:

pip install --upgrade tables

hope that work for you !

yogazining
  • 119
  • 2
  • 10
0

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.

Poojan
  • 3,366
  • 2
  • 17
  • 33
0

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

David Cohen
  • 1
  • 1
  • 1