当前位置:   article > 正文

报错:‘numpy‘ has no attribute ‘float‘._attributeerror: 'numpy.ndarray' object has no attr

attributeerror: 'numpy.ndarray' object has no attribute 'float

报错:

'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.

报错原因:

从numpy1.24起删除了numpy.bool、numpy.int、numpy.float、numpy.complex、numpy.object、numpy.str、numpy.long、numpy.unicode类型的支持。

解决办法

方法一:修改numpy版本
安装numpy1.24之前的版本

pip install numpy==1.23.5

方法二:修改代码

np.float替换为float或者np.float64/np.float3

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/541688
推荐阅读
相关标签
  

闽ICP备14008679号