成功解决ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

在win11电脑上运行ultralytics代码时遇到报错:

UserWarning: Failed to initialize NumPy: DLL load failed while importing _multiarray_umath: 找不到指定的模块。 (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\pytorch\torch\csrc\utils\tensor_numpy.cpp:81.)
  cpu = _conversion_method_template(device=torch.device("cpu"))
ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

应该是conda环境下和pip安装路径的问题,只需要先卸载pip安装的numpy,再使用conda安装一次即可。

pip uninstall numpy
conda install numpy

继续遇到numpy新问题:

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:

这个错误是由于你使用的代码(或依赖的库)中使用了 np.float,而 NumPy 1.20+ 已移除了 np.float 这个 deprecated(弃用)的别名,它原本是 Python 内置 float 的别名。解决方法很简单,核心是将代码中的 np.float 替换为正确的类型。

这个时候就需要你根据代码的实际情况去除np.float中的np了。比如终端报错输出:

    ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float)

需要改为:

   ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=float)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值