AttributeError: module ‘numpy‘ has no attribute ‘int‘.

简介: AttributeError: module ‘numpy‘ has no attribute ‘int‘.

问题描述

运行代码过程中报错:AttributeError: module 'numpy' has no attribute 'int'.


解决方案

在numpy版本更新时 numpy.int 在Numpy 1.20 中已弃用,在Numpy 1.24中已删除。

方案一:重新安装numpy(不推荐,修改版本号可能会引发其他代码错误)

pip uninstall numpy
pip install numpy==1.22


方案二:改代码

找到报错地方,将 np.int 修改为 np.int_

以我的代码举例:

self.sf = np.int(data['sf'][0,...].squeeze().cpu().numpy())


修改为:

self.sf = np.int_(data['sf'][0,...].squeeze().cpu().numpy())

目录
相关文章
|
29天前
|
Python
A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0 as it may crash. To support
本文讨论了在NumPy 2.0.0版本更新后可能出现的兼容性问题,并提供了通过降级NumPy版本至1.x的解决方法,以支持尚未更新的模块或库。
|
1月前
|
Python
module 'numpy' has no attribute 'int'.
module 'numpy' has no attribute 'int'.
74 0
|
4月前
|
Python
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
AttributeError: module ‘numpy‘ has no attribute ‘int‘.
69 0
|
4月前
|
Shell 计算机视觉 Python
no module named cv2 、numpy 、xxx超全解决方案
no module named cv2 、numpy 、xxx超全解决方案
|
4月前
|
Ubuntu 定位技术 Python
numpy库报错has no attribute ‘_no_nep50_warning‘的解决
numpy库报错has no attribute ‘_no_nep50_warning‘的解决
111 1
|
4月前
|
数据采集 分布式计算 数据处理
Dataphin常见问题之与指定类型int不兼容如何解决
Dataphin是阿里云提供的一站式数据处理服务,旨在帮助企业构建一体化的智能数据处理平台。Dataphin整合了数据建模、数据处理、数据开发、数据服务等多个功能,支持企业更高效地进行数据治理和分析。
|
4月前
|
SQL 流计算 OceanBase
OceanBase CDC从热OB库采集过来的Tinyint(1)类型会默认转换成Boolean,请教一下,如果想转换成int类型,有什方法么?
【2月更文挑战第25天】OceanBase CDC从热OB库采集过来的Tinyint(1)类型会默认转换成Boolean,请教一下,如果想转换成int类型,有什方法么?
119 3
|
1月前
|
Java
【Java基础面试五】、 int类型的数据范围是多少?
这篇文章回答了Java中`int`类型数据的范围是-2^31到2^31-1,并提供了其他基本数据类型的内存占用和数值范围信息。
【Java基础面试五】、 int类型的数据范围是多少?
|
1月前
|
自然语言处理 Go 数据安全/隐私保护
对 int 类型的数据加密,有哪些好的方案?
对 int 类型的数据加密,有哪些好的方案?
67 13
|
3月前
|
机器学习/深度学习 人工智能 分布式计算
人工智能平台PAI产品使用合集之int类型是否可以为raw feature
阿里云人工智能平台PAI是一个功能强大、易于使用的AI开发平台,旨在降低AI开发门槛,加速创新,助力企业和开发者高效构建、部署和管理人工智能应用。其中包含了一系列相互协同的产品与服务,共同构成一个完整的人工智能开发与应用生态系统。以下是对PAI产品使用合集的概述,涵盖数据处理、模型开发、训练加速、模型部署及管理等多个环节。