主页 M

AttributeError: module numpy has no attribute int

2023-10-16 网页编程网 网页编程网

1.背景

安装某库时,报错:AttributeError: module numpy has no attribute int. np.int was a deprecated alias for the builtin int. 

2.原因

新版本的numpy里面没有np.int了

3.解决方案

3.1卸载并安装较低的版本

pip uninstall numpy

pip install numpy==1.19.0

3.2修改源码

将原始源码:

ranges = np.round(np.linspace(8, 4, 10), 0).astype(np.int)

修改成:

ranges = np.round(np.linspace(8, 4, 10), 0).astype(int)

4.备注

如果降低numpy版本后,影响到其他的库,可以采用第二种方法。

阅读原文
阅读 873
123 显示电脑版