'Missing optional dependency 'tables'. In pandas to_hdf
- 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')
This is giving me error.
Missing optional dependency 'tables'. Use pip or conda to install tables.
I already tried ImportError HDFStore requires PyTables No module named tables. Still the same error.
I am getting the same error when reading hdf file. And
tablesare already installed for my python.
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.
Solution 1:[1]
- The issue was with
tables. - When i was installing
tablesusing pip into local user directory using following command it's not working.
pip install --user tables
Running
import tableswill 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.exeand installing underc:\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.
Solution 2:[2]
For conda users:
conda install pytables
Solution 3:[3]
I got it to work by using
conda install snappy
Solution 4:[4]
using tables 3.6.1 worked for me to resolve the dependency
pip install tables==3.6.1
Solution 5:[5]
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:
conda env remove -n <env> # remove your virtual env.conda create -n <env> python==3.8 # create your virtual env again.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.
Solution 6:[6]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Matthew |
| Solution 3 | Georgios Koutsakis |
| Solution 4 | Petter Nordin |
| Solution 5 | Poojan |
| Solution 6 | vinzee |
