【已解决】AttributeError: module ‘numpy‘ has no attribute ‘int‘.

报错如图:

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

问题原因:新版本的numpy里面没有np.int了。

【推荐】方法一:找到报错的位置,把np.int改成int就解决了

改成

方法二:

1.先查看现在安装的numpy是什么版本:conda list

降低numpy版本,安装1.20以下的版本,先卸载当前的2.0.1版本:pip uninstall numpy

可以安装1.19.5版本:pip install numpy==1.19.5

出现报错

是由于缺少 distutils 模块,而这个模块是构建 numpy==1.19.0 时所需要的依赖。具体问题是 distutils.msvccompiler 模块未找到,导致无法生成包的元数据。

1.安装distutils:conda install setuptools

2.安装wheel:pip install wheel

3.最后安装1.19.5版本的numpy

现在就能看到numpy版本是1.19.5了

遇到pandasnumpy 版本不兼容这里pandas 版本要求 numpy 版本至少为 1.22.4,而你当前使用的 numpy 版本是 1.19.5。

所以降低pandas版本以适配numpy版本为1.22.4

1.先卸载当前的pandas:pip uninstall pandas

2.安装兼容版本的pandas:通过以下命令安装与 numpy 1.19.5 兼容的 pandas 版本,例如 pandas 1.3.5:pip install pandas==1.3.5

3.确认版本匹配:安装完成后,你可以检查当前安装的 pandasnumpy 版本,确保它们是兼容的:

这样,pandas 1.3.5 应该会与 numpy 1.19.5 兼容,从而解决版本不匹配的问题。

遇到matplotlib和 numpy 版本不兼容

降低 matplotlib 版本

因为希望保持当前的 numpy 1.19.5 版本不变,可以通过安装与其兼容的较低版本的 matplotlib

  1. 卸载当前的 matplotlib:pip uninstall matplotlib

  2. 安装兼容的 matplotlib 版本(例如 matplotlib 3.4.3:pip install matplotlib==3.4.3

  3. 验证安装: 确保安装了正确的 matplotlib 版本:python -c "import matplotlib; print(matplotlib.__version__)"
     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值