【Bug纠错】Numpy2.1.1版本程序运行报错解决

学习深度学习时,使用pytorch时遇到numpy报错问题


一、问题描述

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

  • 翻译:

使用 NumPy 1.x 编译的模块无法在NumPy 2.1.1 的版本,因为它可能会崩溃。同时支持 1.x 和 2.x版本的 NumPy 中,模块必须使用 NumPy 2.0 进行编译。某些模块可能需要重新构建,例如使用 ‘pybind11>=2.12’ 。

如果您是该模块的用户,最简单的解决方案是降级到“numpy<2”或尝试升级受影响的模块。我们预计某些模块需要时间来支持 NumPy 2。

❗大致问题描述就是:
“numpy版本原因导致部分模块编译不通过,从而引起程序崩溃,需要替换numpy2.0以下的版本。”

二、解决办法

  • 查询numpy版本后,发现是2.1.1,而python版本是3.11.9

在这里插入图片描述
在这里插入图片描述

经过网上搜索,发现numpy版本和python版本有对应关系

  • 查询numpy官网对应版本

在这里插入图片描述

  • 重新安装对应版本numpy
    (1)删除原先版本
pip uninstall Numpy

提示删除成功,但是仍有部分文件需手动删除
在这里插入图片描述
(2)安装对应版本numpy 1.26

pip install numpy==1.26.0
conda list

在这里插入图片描述

小结

安装一些依赖包时,不能图省事,还得看清楚对应版本再安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值