无法导入numpy:AttributeError:类型对象'numpy.ndarray'没有属性'__array_function__'

时间:2019-01-14 06:39:39

标签: python python-3.x pandas numpy

我正在尝试导入numpy,但出现以下错误:

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__'

如何解决此问题?

2 个答案:

答案 0 :(得分:4)

我有同样的问题。 刚运行

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

pip3 install numpy

对我有用。

答案 1 :(得分:-1)

删除python3.6 / site-packages中的整个numpy目录和numpy光盘信息 和类型 pip3安装numpy

我今天遇到同样的问题