3

I am trying to import numpy but I am getting following error:

AttributeError                            Traceback (most recent call last)
<ipython-input-3-38d4b0363d82> in <module>()
----> 1 import pandas

/home/oto/.local/lib/python3.6/site-packages/pandas/__init__.py in <module>()
     11 for dependency in hard_dependencies:
     12     try:
---> 13         __import__(dependency)
     14     except ImportError as e:
     15         missing_dependencies.append(dependency)

/home/oto/.local/lib/python3.6/site-packages/numpy/__init__.py in <module>()
    140     from . import _distributor_init
    141 
--> 142     from . import core
    143     from .core import *
    144     from . import compat

/home/oto/.local/lib/python3.6/site-packages/numpy/core/__init__.py in <module>()
     57 from . import numerictypes as nt
     58 multiarray.set_typeDict(nt.sctypeDict)
---> 59 from . import numeric
     60 from .numeric import *
     61 from . import fromnumeric

/home/oto/.local/lib/python3.6/site-packages/numpy/core/numeric.py in <module>()
   3091 from .umath import *
   3092 from .numerictypes import *
-> 3093 from . import fromnumeric
   3094 from .fromnumeric import *
   3095 from . import arrayprint

/home/oto/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py in <module>()
     15 from . import numerictypes as nt
     16 from .numeric import asarray, array, asanyarray, concatenate
---> 17 from . import _methods
     18 
     19 _dt_ = nt.sctype2char

/home/oto/.local/lib/python3.6/site-packages/numpy/core/_methods.py in <module>()
    156     )
    157 
--> 158 _NDARRAY_ARRAY_FUNCTION = mu.ndarray.__array_function__
    159 
    160 def _array_function(self, func, types, args, kwargs):

AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'

How to solve this issue ?

15
  • Have you tried re-installing numpy? Also, is this standalone or Anaconda distribution? Commented Jan 14, 2019 at 6:50
  • @amanb yes, I did. Its standalone Commented Jan 14, 2019 at 6:52
  • do you have any numpy.py file in your project?if yes rename it and its .pyc file. Commented Jan 14, 2019 at 6:56
  • @Adithya there is not numpy.py file Commented Jan 14, 2019 at 6:59
  • from the Traceback it seems the problem is with pandas try reinstalling pandas Commented Jan 14, 2019 at 7:02

2 Answers 2

4

I had the same problem. Just run

rm -rf /home/oto/.local/lib/python3.6/site-packages/numpy*

pip3 install numpy

It worked for me.

Sign up to request clarification or add additional context in comments.

Comments

-1

remove the whole numpy directory and numpy disc info in the python3.6/site-packages and type pip3 install numpy

I just encounter the same problem today

1 Comment

You're repeating the answer given above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.