如何在 Windows 上使用 iPython Notebook 解决 pandas 的导入错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30945272/
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
How to solve import error for pandas using iPython Notebook on Windows?
提问by Greg Carter
I'm trying to import pandas while using iPython. My overall purpose is to use XLwings.
我正在尝试在使用 iPython 时导入Pandas。我的总体目的是使用 XLwings。
I'm on Windows 7 and have used Anaconda to install Python, pandas and all the dependencies.
我在 Windows 7 上使用 Anaconda 安装 Python、pandas 和所有依赖项。
Here is my code:
这是我的代码:
from pandas import DataFrame
Which gives:
这使:
ImportError Traceback (most recent call last)
<ipython-input-7-26dfcabfb474> in <module>()
----> 1 from pandas import DataFrame
C:\Users\Accounting\Anaconda\lib\site-packages\pandas\__init__.py in <module>()
11 "pandas from the source directory, you may need to run "
12 "'python setup.py build_ext --inplace' to build the C "
---> 13 "extensions first.".format(module))
14
15 from datetime import datetime
ImportError: C extension: hashtable not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
Can anyone with experience of using Python/pandas in iPython on Windows help me understand how to solve this error?
任何有在 Windows 上的 iPython 中使用 Python/pandas 经验的人都可以帮助我理解如何解决这个错误吗?
Specifically where do I run "python setup.py build_ext --inplace"?
具体在哪里运行“python setup.py build_ext --inplace”?
Thanks!
谢谢!
回答by Greg Carter
As posted by Jeff in the comments:
正如杰夫在评论中发表的那样:
There is a bug in older versions (of conda) where if you had updated pandas WHILE it was being used it didn't update correctly. Try closing all python processes, then
旧版本(conda)中存在一个错误,如果您在使用Pandas时更新了它,则它不会正确更新。尝试关闭所有 python 进程,然后
conda remove pandas
conda install pandas
回答by WearableQueen
I found while installing packages (most from Christoph Gohlke), sometimes you have to use "pip install name of .whl" (in proper path to package) and initially adding a "C:/miscutilities" to Environmental Variables PATH if it wouldn't install from the Anaconda -> Lib -> site-packages. Then some other packages I used conda.
我发现在安装软件包时(大部分来自 Christoph Gohlke),有时您必须使用“.whl 的 pip 安装名称”(在正确的软件包路径中)并最初向环境变量 PATH 添加一个“C:/miscutilities”,如果它不会的话t 从 Anaconda -> Lib -> 站点包安装。然后我使用了 conda 的其他一些包。

