[最全解答]import torch出现No module named 'numpy.core._multiarray_umath'错误

本文针对在导入torch时遇到的'numpy.core._multiarray_umath'模块缺失错误,提供了多种解决方案,包括更新numpy版本,调整pip和conda环境,及明确Python环境路径等方法,帮助读者有效解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import torch出现No module named 'numpy.core._multiarray_umath’错误

网上常见解答:
1.更新numpy到最新版本

pip install -U numpy

2.更新pip到最新版本,再使用pip将numpy更新到最新版本

python -m pip install --upgrade pip
pip install -U numpy

3.使用Anoconda的人,将pip下载的numpy卸载,使用conda重新下载numpy

pip uninstall numpy   //在pip中卸载numpy

conda install numpy //在conda中重新安装numpy

4.根据配置环境,手动选择numpy+mkl号,重新下载

问题原因:
我出现问题的原因也是因为numpy版本的问题,但是更新一直没弄好。
因为电脑刚安装了Anaconda,还有之前安装的python3.6和python2.7,因此包的安装环境比较混乱,不知道当前使用的是哪一个,pip更新的又是哪一个。
最终根据报错里面提示的路径,找到了目前使用的是哪个python,然后更新numpy就没有问题了。

划重点:
像我一样,电脑中安装了多版本的python的朋友,记得一定要搞清楚是哪一个环境出现了问题,更新之后,要记得看对应的文件是否有所更新!确保达到效果。

Traceback (most recent call last): File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\numpy\_core\__init__.py", line 23, in <module> from . import multiarray File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\numpy\_core\multiarray.py", line 10, in <module> from . import overrides File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\numpy\_core\overrides.py", line 7, in <module> from numpy._core._multiarray_umath import ( add_docstring, _get_implementing_args, _ArrayFunctionDispatcher) ModuleNotFoundError: No module named 'numpy._core._multiarray_umath' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\numpy\__init__.py", line 127, in <module> from numpy.__config__ import show_config File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\numpy\__config__.py", line 4, in <module> from numpy._core._multiarray_umath import ( ...<3 lines>... ) File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\Lib\site-packages\numpy\_core\__init__.py", line 49, in <module> raise ImportError(msg) ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.13 from "C:\Users\Lenovo\AppData\Local\Programs\Python\Python313\python.exe" * The NumPy version is: "2.2.4" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No mo
04-02
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值