pandas 在 iPython 中使用 HDF5 文件时出现异常“HDFStore 需要 PyTables”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15469594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 20:43:09  来源:igfitidea点击:

Exception 'HDFStore requires PyTables ' when using HDF5 file in iPython

pythonpandashdf5

提问by learn_code

I am very new to Python and am trying to create a table in pandas with HDFStore as follows

我对 Python 非常陌生,正在尝试使用 HDFStore 在 Pandas 中创建一个表,如下所示

store = HDFStore('store.h5')

I get the exception :

我得到了例外:

Exception                                 Traceback (most recent call last)
C:\Python27\<ipython-input-11-de3060b689e6> in <module>()
----> 1 store = HDFStore('store.h5')

C:\Python27\lib\site-packages\pandas-0.10.1-py2.7-win32.egg\pandas\io\pytables.pyc in __init__(self, path, mode, complevel, complib, fletcher32)
    196             import tables as _
    197         except ImportError:  # pragma: no cover
--> 198             raise Exception('HDFStore requires PyTables')
    199 
    200         self.path = path

Exception: HDFStore requires PyTables 

I already have Pytables installed and it is present in site-packages. Both pandas(0.l0.1) and pytables(2.4.0) are 32 bit Windows versions. Python version is 2.7.3 for 32 bit windows

我已经安装了 Pytables,它存在于站点包中。pandas(0.l0.1) 和 pytables(2.4.0) 都是 32 位 Windows 版本。Python 版本为 2.7.3,适用于 32 位 Windows

I am running this using ipython notebook.

我正在使用 ipython notebook 运行它。

I forgot to add that I have Windows 7 - 64 bit OS, but Python and all its related add-ons are 32 bit.

我忘了补充一点,我有 Windows 7 - 64 位操作系统,但 Python 及其所有相关的附加组件都是 32 位的。

回答by Tharindu Kumara

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.

使用HDFStore时我也遇到了同样的错误。我尝试了上面指定的所有步骤,并花了很多时间寻找解决方案,但没有一个成功。

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

然后我下载并安装了MiniConda。然后我使用下面的命令来安装 pytables。

conda install -c conda-forge pytables

Please refer the below screenshot.

请参考以下屏幕截图。

enter image description here

在此处输入图片说明

回答by agconti

I suspect your problem is that you have not added Python Scripts to your system PATH. Assuming that check out this tutorialon how to do it.

我怀疑您的问题是您没有将 Python 脚本添加到您的系统中PATH。假设查看本教程了解如何操作。

You are looking to add the C:\Python27, C:\Python27\Lib. and C:\Python27\Scripts. Make sure you separate each one with a ;. Also make sure you add it to your system PATHvariable and not just your user PATHvariable.

您正在寻找添加C:\Python27, C:\Python27\Lib. and C:\Python27\Scripts. 确保用;. 还要确保将其添加到系统PATH变量中,而不仅仅是用户PATH变量。

after all of that check import pytables. It should no longer throw and error, because python will be 'know' that pytables is installed and be able to locate it.

毕竟那检查import pytables。它应该不再抛出和错误,因为 python 将“知道”pytables 已安装并能够找到它。

回答by Vic Liu

I had same problem. I am using win7 + anaconda python2.7 + IPython.

我有同样的问题。我正在使用 win7 + anaconda python2.7 + IPython。

But I fixed it with following steps:

但我通过以下步骤修复了它:

From http://www.lfd.uci.edu/~gohlke/pythonlibs/#pytables
download file tables?3.2.1?cp27?none?win_amd64.whl

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pytables
下载文件表?3.2.1?cp27?none?win_amd64.whl

and install it with cmd

然后用cmd安装

pip install tables?3.2.1?cp27?none?win_amd64.whl

after installed problem solved.

安装后问题解决。

ref: http://www.pytables.org/usersguide/installation.html#binary-installation-windows

参考:http: //www.pytables.org/usersguide/installation.html#binary-installation-windows