import pandas : ImportError: cannot import name Counter in python 2.6.6

3.1k Views Asked by At

I am using python 2.6.6

I installed pandas as follows

pip install pandas

I got the following success message as well

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

However now when am importing it

import pandas as pd

It gives me the following error

>>> 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

What is missing here?

Edit: I installed backport_collections 0.1 and tried again. It still gives error

2

There are 2 best solutions below

0
Shijo On BEST ANSWER

try installing Pandas from this package

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

6
Moses Koledoye On

The pandas library uses the collections.Counter object which was introduced in Python 2.7; there's nothing to import in 2.6.

I think the easiest way around this is an upgrade to Python 2.7