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

0 votes

Hi Guys,

I installed numpy module in my system. But when I tried to import this module in python prompt, I got this error.

>>>import numpy
 Traceback (most recent call last):
      File "/home/trey/script.py", line 6, in <module>
        import numpy as np
      File "/home/trey/.local/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
        from . import core
      File "/home/trey/.local/lib/python3.6/site-packages/numpy/core/__init__.py", line 59, in <module>
        from . import numeric
      File "/home/trey/.local/lib/python3.6/site-packages/numpy/core/numeric.py", line 3093, in <module>
        from . import fromnumeric
      File "/home/trey/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 17, in <module>
        from . import _methods
      File "/home/trey/.local/lib/python3.6/site-packages/numpy/core/_methods.py", line 158, in <module>
        _NDARRAY_ARRAY_FUNCTION = mu.ndarray.__array_function__
    AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'

How can I solve this error?

Apr 13 in Python by akhtar
• 10,580 points
180 views

1 answer to this question.

0 votes

Hi@akhtar,

I think numpy version is not compatible with python. So try to upgrade your numpy module using the below given command.

$ pip3 install --upgrade numpy
Installing collected packages: numpy
Successfully installed numpy-1.16.0
$ python3 
Python 3.5.2 (default, Apr 13 2020, 13:01:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> 

Hope this will help.

answered Apr 13 by MD
• 23,050 points

Related Questions In Python

0 votes
1 answer

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Hi, @Bronson, You can go through this, I ...READ MORE

answered Apr 6 in Python by Gitika
• 29,290 points
406 views
0 votes
1 answer

'numpy.ndarray' object has no attribute 'append'

Hi@Noman, You created two empty list. And in ...READ MORE

answered May 17 in Python by MD
• 23,050 points
257 views
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,540 points
3,025 views
0 votes
1 answer
0 votes
1 answer

How to rename columns in pandas (Python)?

It is easy by just adding ".columns" ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
311 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
973 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
5,051 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,560 points
2,792 views
0 votes
1 answer
0 votes
1 answer