Pandas 无法导入 IPython

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10449663/
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 15:42:46  来源:igfitidea点击:

Pandas cannot be imported into IPython

pythonwindowspandaspython-2.7ipython

提问by Michele Reilly

I am running Windows 7.0, with Python2.7. I installed pandas before installing ipython0.12.1(stable).

我正在运行Windows 7.0,与Python2.7. 我在安装之前安装了熊猫ipython0.12.1(稳定)。

When I run import pandasin IPython.exeI get the error message:

当我运行时import pandasIPython.exe我收到错误消息:

No module named pandas

没有名为 pandas 的模块

If I call IPython from the start menu, via cmd it doesn't automatically run in C:\Python27where pandas is located. Instead it runs in a different path C:\Users\mycomputername\\.ipython. (It seems unreasonable that ipython would not be able to detect that the pandas library exists on the machine).

如果我从开始菜单调用 IPython,通过 cmd 它不会自动运行在C:\Python27Pandas 所在的位置。相反,它运行在不同的路径中C:\Users\mycomputername\\.ipython。(ipython无法检测到机器上存在pandas库似乎不合理)。

That being said, I also cd into C:\Python27\dist\ipython-0.12folder to run ipython.exefrom there, where the appropriate libraries i.e. distribute-0.6.26and pyreadline-1.7.1were installed.

话虽如此,我也 cd 进入C:\Python27\dist\ipython-0.12文件夹以ipython.exe从那里运行,其中安装了适当的库 iedistribute-0.6.26pyreadline-1.7.1

I still receive that error message. Does anyone know if the order of installation is particular on Windows7?

我仍然收到该错误消息。有谁知道安装顺序在Windows7上是否特定?

回答by Wes McKinney

Do you have multiple versions of Python? Something must be borked with your Python path. Have a look at sys.path:

你有多个版本的 Python 吗?你的 Python 路径必须有一些东西。看看 sys.path:

import sys
for x in sys.path: print x

pandas should be installed in C:\Python27\Lib\site-packages\pandasor in an egg directory there. You can find out exactly where by firing up the regular python interpreter and doing

pandas 应该安装在其中C:\Python27\Lib\site-packages\pandas的 egg 目录中。你可以通过启动常规的 python 解释器并做

import pandas print pandas

import pandas print pandas

Not sure what could be wrong in IPython.

不确定 IPython 中可能有什么问题。

回答by aybuke

I had the same problem. So the reason on my end was because I had the multiple versions of Python. Since, I had the other system before using iPython the directory was calling the very first version on the Python.

我有同样的问题。所以我最终的原因是因为我有多个版本的 Python。因为,在使用 iPython 之前我有另一个系统,该目录正在调用 Python 上的第一个版本。

What to do:

该怎么办:

1) check if you have the right Python path

1) 检查你是否有正确的 Python 路径

import sys  
for x in sys.path: print x

2) If not delete the other version, if you really do not need many versions of Python.

2)如果不删除其他版本,如果你真的不需要很多版本的Python。

That solved my problem.

那解决了我的问题。