Surya Sekhar Mondal
Surya Sekhar Mondal

Reputation: 179

A module of Python-2.7 not getting imported when it is definitely installed

My pandas package is not getting imported. When I try to check if I have pandas using the command

python -c "import pandas"

It shows some strange error like

<module 'numpy' from 'numpy.pyc'>
'module' object has no attribute 'dtype'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pandas/__init__.py", line 6, in   <module>
from . import hashtable, tslib, lib
File "numpy.pxd", line 157, in init pandas.hashtable    (pandas/hashtable.c:21706)
AttributeError: 'module' object has no attribute 'dtype'

Upvotes: 1

Views: 97

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121524

You have a local file named numpy.py which is being imported instead of the globally installed NumPy project:

<module 'numpy' from 'numpy.pyc'>

Remove or rename that file and delete the associated numpy.pyc file next to it. Your local file has no name dtype, only the numpy package installed in your site-packages does, but it can't be loaded when your file is found first every time.

Upvotes: 2

Related Questions