I upgraded numpy to the latest version and now I am getting following error on importing numpy:
AttributeError: type object 'numpy.ndarray' has no attribute 'array_function'
I am using numpy version 1.16.
Uninstall all installs of Numpy using
pip uninstall numpy
for python3
pip3 uninstall numpy
You may need to run the uninstall command several times since several versions of numpy may be installed. Then run
pip install numpy
This seems to be an ongoing issue (with the recent release of Numpy 1.16.0
there was a rash of related bug reports). There's a whole bunch more info about the causes of and fixes for this bug on an issue thread on Numpy's Github.
As described in the issue, the problem is caused by path conflicts between the files of different Numpy versions. They also suggest that there may be an issue with older versions of pip
(specifically, there used to be an issue with how pip
uninstalled (or failed to uninstall) old versions of Numpy).
The Numpy dev recommend fix is to first upgrade your pip
:
pip install -U pip
then uninstall/reinstall the latest version of Numpy (this does both in a single command):
pip install -U numpy
Some people ended up having stranger path conflicts that they were unable to resolve just by reinstalling with pip
. If the above steps fail, check to see if you have any old installs of Numpy anywhere on your filesystem. If you do, get rid of them and then try reinstalling Numpy again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With