我已经在 python 3.3 上安装了 Pandas,并且编码如下:
import csv
import pandas
from pandas import DataFrame
csvdata = pandas.read_csv('datafile.csv')
df = DataFrame(csvdata)
它带有以下错误消息:
cannot import name hashtable
Traceback (most recent call last):
File "C:\Users\document\test4.py", line 5, in <module>
import pandas
File "C:\Python33\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable
谁能帮我弄清楚如何解决这个错误? Python和pandas安装成功。
请您参考如下方法:
更新:我现在建议使用 Anaconda 安装科学 Python 堆栈。 .
Pandas 是捆绑的,可以使用 conda 轻松更新:
conda update pandas
它还与 cython、scipy(通过 pip 安装很棘手)、statsmodels 捆绑在一起,并为您管理这些包之间的依赖关系/关系。
值得强调的是,在安装 Anaconda 的机器上安装它不需要 admin/sudo 访问权限。
如果您没有使用 Anaconda,推荐的方法是 install pandas是通过 pip(在 Mac 和 Windows 上):
pip install pandas
在 Linux 上,您也可以使用
python-pandas 安装在任何存储库中,但请注意,您可能正在安装旧版本的 Pandas,理想情况下,您应该使用最新的稳定版本。
看起来您已经尝试过 install from source ,文档中提到:
Installing from the git repository requires a recent installation of Cython as the cythonized C sources are no longer checked into source control. Released source distributions will contain the built C files. I recommend installing the latest Cython via
easy_install -U CythonNote that you will not be able to import pandas if you open an interpreter in the source directory unless you build the C extensions in place:
python setup.py build_ext --inplace
无需编译
hashtables.pyx (以及其他一些 cython 文件),pandas 无法导入它们。这些是 Pandas 所必需的(这解释了您的错误消息)。
注意:这个 error message has been made more descriptive for 0.11.1 onwards ,它会说没有构建 C 扩展。

