import pandas:ImportError:无法在python 2.6.6中导入名称Counter

时间:2016-12-20 15:31:07

标签: python python-2.6

我正在使用python 2.6.6

我按如下方式安装了熊猫

pip install pandas

我也收到了以下成功消息

Building wheels for collected packages: pandas
  Running setup.py bdist_wheel for pandas ... done
  Stored in directory: /root/.cache/pip/wheels/81/18/d5/9f087d2b2763f0573195c75f297cac96125d02dbb5aef2297b
Successfully built pandas
Installing collected packages: six, python-dateutil, pytz, pandas
Successfully installed pandas-0.19.1 python-dateutil-2.6.0 pytz-2016.10 six-1.10.0

但现在在导入时

import pandas as pd

它给我以下错误

>>> import pandas as pd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat.numpy import *
  File "/usr/lib64/python2.6/site-packages/pandas/compat/__init__.py", line 333, in <module>
    from collections import OrderedDict, Counter
ImportError: cannot import name Counter

这里缺少什么?

修改 我安装了backport_collections 0.1并再次尝试。它仍然给出错误

2 个答案:

答案 0 :(得分:2)

pandas库使用Python 2.7中引入的collections.Counter对象;在2.6中没有任何东西可以导入。

我认为最简单的方法是升级到Python 2.7

答案 1 :(得分:2)

尝试从此软件包安装Pandas

https://pypi.python.org/pypi/pandas/0.16.2/