安装pandas时,获取'module'对象没有属性'Series'

时间:2014-02-04 01:53:15

标签: python pandas

我希望能够在我的计算机上使用Pandas来处理数据。我已经能够在iPython笔记本中做到这一点。但是在我的电脑上,当我尝试使用Pandas的任何东西时,我得到以下结果:

Traceback (most recent call last):
  File "/Users/Desktop/pandas.py", line 1, in <module>
    import pandas as pd
  File "/Users/Desktop/pandas.py", line 7, in <module>
    s = pd.Series([1,3,5,np.nan,6,8])
AttributeError: 'module' object has no attribute 'Series'
[Finished in 0.1s with exit code 1]

我已经检查过以确保我的计算机上安装了pandas。当我运行pip install pandas时,我得到:

Requirement already satisfied (use --upgrade to upgrade): pandas in /anaconda/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /anaconda/lib/python2.7/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in /anaconda/lib/python2.7/site-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in /anaconda/lib/python2.7/site-packages (from pandas)
Cleaning up...

似乎表明已经安装了pandas。

1 个答案:

答案 0 :(得分:0)

您是否检查过您使用的是哪个版本的python?看来你在python27中安装了pandas。是用python27编写的脚本的回溯吗?如果没有,那将导致问题。

这个问题的答案有一个很好的解释:Installed Python Modules - Python can't find them