Pandas: AttributeError: 'module' object has no attribute '__version__'

Question:

When I try to import pandas into Python I get this error:

>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/__init__.py", line 44, in <module>
    from pandas.core.api import *
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/api.py", line 9, in <module>
    from pandas.core.groupby import Grouper
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/groupby.py", line 17, in <module>
    from pandas.core.frame import DataFrame
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/frame.py", line 41, in <module>
    from pandas.core.series import Series
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/series.py", line 2909, in <module>
    import pandas.tools.plotting as _gfx
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/tools/plotting.py", line 135, in <module>
    if _mpl_ge_1_5_0():
  File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/tools/plotting.py", line 130, in _mpl_ge_1_5_0
    return (matplotlib.__version__  >= LooseVersion('1.5')
AttributeError: 'module' object has no attribute '__version__'

But when I check if pandas is installed:

me$ conda install pandas
Fetching package metadata: ....
Solving package specifications: .....................
# All requested packages already installed.
# packages in environment at /Users/me/miniconda2:
#
pandas                    0.17.1              np110py27_0  

So I don’t know what is wrong? What is going on with my pandas?

Edit

$ pip list |grep matplotlib
$ conda list matplotlib
# packages in environment at /Users/me/miniconda2:
#
matplotlib                1.5.0               np110py27_0 

For some reason there was no output to pip list |grep matplotlib

Edit2

I wanted to see if there was a different path to the executables ipython and python. So I ran this:

$ python
>>> import sys
>>> print sys.executable 
/Users/me/miniconda2/bin/python

However in IPython, I get this:

$ ipython notebook
>>> import sys
>>> print sys.executable
/usr/local/opt/python/bin/python2.7

Could that be the problem?

Asked By: Chef1075

||

Answers:

Remove (or rename) the file matplotlib.py from your current working directory. It shadows the real library with the same name.

Answered By: Mike Müller

I have a simple solution,delete your __init__.pyc and __init__.py files in your project dictionary. because i encounter the problem too,I have been solve it perfectly use this method.

Answered By: Lee Ran

It worked for me

pip install pyparsing==2.4.7
Answered By: Robin Reni
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.