53
import pandas as pd
dfs = pd.HDFStore('xxxxx.h5')

throws this error:

"ImportError: HDFStore requires PyTables, "No module named tables" problem importing"

I tried to install PyTables, which Requires Cython. I have Cython 0.21 installed, but it is throwing an error stating that Cython should be greater than 0.13

Here is the log that I am getting:

".. ERROR:: You need Cython 0.13 or greater to compile PyTables!

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/tmp/pip_build_root/tables
Storing debug log for failure in /Users/nikhilsahai/Library/Logs/pip.log
Nikhils-MacBook-Pro:~ nikhilsahai$ sudo pip install cython
Requirement already satisfied (use --upgrade to upgrade): cython in /Library/Python/2.7/site-packages/Cython-0.21-py2.7-macosx-10.9-intel.egg
Cleaning up..."

Please guide me how to do solve this issue.

JJJ
  • 1,009
  • 6
  • 19
  • 31
nikhil sahai
  • 531
  • 1
  • 5
  • 4
  • I assume you have some paths crossed and setup.py is findinging one version of cython and pip is finding a different one. – tacaswell Sep 22 '14 at 18:07
  • yeh, you need a much greater version of cython, 0.21 is the current – Jeff Sep 22 '14 at 18:22
  • It's a bug in the released version of pytables: https://github.com/PyTables/PyTables/issues/388. It's fixed in the dev version. Which you can install with `pip install git+https://github.com/PyTables/PyTables` – TomAugspurger Sep 22 '14 at 18:51

7 Answers7

52

Simply updating pytables with:

pip install --upgrade tables

worked for me.

lin_bug
  • 1,125
  • 11
  • 10
26

I also had the same error when using HDFStore. And I tried all the steps specified above and spent many hours to find a solution, but non of them were successful.

Then I downloaded and installed MiniConda. And then I used the below command to install pytables.

conda install -c conda-forge pytables

Please refer the below screenshot.

enter image description here

Tharindu Kumara
  • 4,398
  • 2
  • 28
  • 46
18

On Ubuntu, I solved this problem using this command:

sudo apt-get install python3-tables

Note that I am using Python 3

Tarik
  • 10,810
  • 2
  • 26
  • 40
  • or `pkg install py27-tables-3.2.2_1` – Oliver Angelil Dec 12 '16 at 09:43
  • 10
    or just `pip install tables` for python 3 – Shadi Jan 05 '18 at 11:14
  • @shadi I use Linux and prefer to stick to the package manager. – Tarik Jan 06 '18 at 16:01
  • 1
    You're kind of restricting your options unnecessarily. With pip you can choose different versions. Pip is also a package manager btw. – Shadi Jan 06 '18 at 16:03
  • 2
    @shadi Read this article: http://matthew-brett.github.io/pydagogue/installing_on_debian.html. It has a balanced view explaining the pros and cons of apt-get vs pip. I prefer using apt-get for stability reasons, others prefer pip to get other benefits such as better control on the package they want. It also seems preferable to use virtualenv in conjunction with pip. – Tarik Jan 20 '18 at 23:49
  • Valid points. I use [pew](https://github.com/berdario/pew) as a wrapper for virtualenv – Shadi Jan 22 '18 at 11:31
  • Using a dockerfile (with the base image of python3-slim), adding ```ENV HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial```, and installing both ```apt-get install libhdf5-serial-dev``` and ```pip install tables``` seemed to work. Other solutions didn't work for me. – morganics Oct 02 '18 at 14:17
6

You can use pip on any os :

python -m pip install tables

You can check the official documentation on more ways to install it http://www.pytables.org/usersguide/installation.html

SEDaradji
  • 1,348
  • 15
  • 18
  • I can confirm: this solves the problem on MacOS and both python2 and python3 (`python2 -m pip install tables` and `python3 -m pip install tables`) – normanius Nov 17 '17 at 13:04
2

As TomAugspurger mentioned... It seems there is a bug with the latest version of pytables. You can install the current development version by executing the following command:

sudo pip install git+https://github.com/PyTables/PyTables

If it solved the problem, the question should be closed :)

joanfihu
  • 336
  • 2
  • 9
2

You have to install pytables:

conda install pytables

hoaphumanoid
  • 977
  • 1
  • 9
  • 25
1

On Windows,maybe that is a good choices,using this Command:

pip installed tables-3.2.2-cp34-cp34m-win_amd64.whl

---the document you can download from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy