【问题标题】:Exception 'HDFStore requires PyTables ' when using HDF5 file in iPython在 iPython 中使用 HDF5 文件时出现异常“HDFStore 需要 PyTables”
【发布时间】:2013-03-06 08:42:17
【问题描述】:

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

store = HDFStore('store.h5')

我得到了例外:

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 

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

我正在使用 ipython notebook 运行它。

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

【问题讨论】:

  • 如果你运行import tables会发生什么?
  • 引发导入错误:ImportError Traceback (most recent call last) C:\Python27\&lt;ipython-input-12-389ecae14f10&gt; in &lt;module&gt;() ----&gt; 1 import tables C:\Python27\lib\site-packages\tables\__init__.py in &lt;module&gt;() 67 68 # Necessary imports to get versions stored on the cython extension ---&gt; 69 from tables.utilsExtension import getPyTablesVersion, getHDF5Version 70 71 ImportError: cannot import name getPyTablesVersion
  • 我忘了补充说我有 Windows 7 - 64 位操作系统,但是 Python 和所有相关的附加组件都是 32 位的,这可能是个问题吗?
  • 我不这么认为。你是如何安装 pytables 的?你确定一切都编译了吗?您可以尝试使用其中一个设置文件from here
  • 谢谢,我回过头来发现我没有正确编译它,因为我没有安装HDF5库。

标签: python pandas hdf5


【解决方案1】:

我怀疑您的问题是您尚未将 Python 脚本添加到您的系统 PATH。假设查看this tutorial 了解如何操作。

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

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

【讨论】:

    【解决方案2】:

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

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

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

    然后用 cmd 安装

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

    安装后问题解决。

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

    【讨论】:

      【解决方案3】:

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

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

      conda install -c conda-forge pytables
      

      请参考以下截图。

      【讨论】:

        猜你喜欢
        • 2016-08-05
        • 2016-11-12
        • 2015-03-31
        • 2015-11-22
        • 2011-12-21
        • 2017-07-28
        • 1970-01-01
        • 2015-10-10
        相关资源
        最近更新 更多