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

后端 未结 2 1022
栀梦
栀梦 2021-01-02 12:38

I upgraded numpy to the latest version and now I am getting following error on importing numpy:

AttributeError: type object \'numpy.ndarray\' has no a

相关标签:
2条回答
  • 2021-01-02 13:10

    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.

    0 讨论(0)
  • 2021-01-02 13:11

    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
    
    0 讨论(0)
提交回复
热议问题