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

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.

The problem

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 fix

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

If that doesn't work

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.