一、问题描述
运行代码出现以下numpy报错
AttributeError: module 'numpy' has no attribute 'int'
二、问题原因
python或numpy版本问题导致的。numpy版本更新时的numpy.int 在NumPy 1.20中已弃用,在NumPy 1.24中已被删除,所以没有numpy.int。
三、解决方法
1.更换python或numpy版本
pip uninstall numpy
pip install numpy==1.22
2.将报错的地方进行如下修改:
将numpy.int替换为numpy.int_
注:有任何问题欢迎评论区交流讨论或者私信!