找回密码
 会员注册
查看: 21|回复: 0

Python提示‘ModuleNotFoundErrorNomodulenamed‘numpy.core._multiarray_umath‘

[复制链接]

2万

主题

0

回帖

7万

积分

超级版主

积分
72033
发表于 2024-9-8 11:05:33 | 显示全部楼层 |阅读模式
一、问题背景       在学习Python编程使用matplotlib时,总是提示:ModuleNotFoundError:Nomodulenamed'numpy.core._multiarray_umath'问题大致描述如下:D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\Scripts\python.exeD:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\part2\visable\tet.pyTraceback(mostrecentcalllast):File"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\core\__init__.py",line24,infrom.importmultiarrayFile"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\core\multiarray.py",line10,infrom.importoverridesFile"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\core\overrides.py",line8,infromnumpy.core._multiarray_umathimport(ModuleNotFoundError:Nomodulenamed'numpy.core._multiarray_umath'Duringhandlingoftheaboveexception,anotherexceptionoccurred:Traceback(mostrecentcalllast):File"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\__init__.py",line159,infromnumpy.__config__importshowasshow_configFile"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\__config__.py",line4,infromnumpy.core._multiarray_umathimport(File"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\core\__init__.py",line50,inraiseImportError(msg)ImportError:IMPORTANTLEASEREADTHISFORADVICEONHOWTOSOLVETHISISSUE!ImportingthenumpyC-extensionsfailed.Thiserrorcanhappenformanyreasons,oftenduetoissueswithyoursetuporhowNumPywasinstalled.Wehavecompiledsomecommonreasonsandtroubleshootingtipsat:https://numpy.org/devdocs/user/troubleshooting-importerror.htmlPleasenoteandcheckthefollowing:*ThePythonversionisython3.10from"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\Scripts\python.exe"*TheNumPyversionis:"1.26.4"andmakesurethattheyaretheversionsyouexpect.Pleasecarefullystudythedocumentationlinkedaboveforfurtherhelp.Originalerrorwas:Nomodulenamed'numpy.core._multiarray_umath'Theaboveexceptionwasthedirectcauseofthefollowingexception:Traceback(mostrecentcalllast):File"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\part2\visable\tet.py",line1,inimportmatplotlib.pyplotaspltFile"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\matplotlib\__init__.py",line184,inimportnumpyFile"D:\WorkSpace\PythonWorkSpace\Python编程-从入门到实践\venv\lib\site-packages\numpy\__init__.py",line164,inraiseImportError(msg)fromeImportError:Errorimportingnumpy:youshouldnottrytoimportnumpyfromitssourcedirectory;pleaseexitthenumpysourcetree,andrelaunchyourpythoninterpreterfromthere.Processfinishedwithexitcode11234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556二、解决思路       上述错误的原因是找不到matplotlib所在包,类似于java中的找不到依赖,基于此种原因,有两个解决思路:首先应该确保已经正确安装呆matplotlib包,这样才能正确导入包确保项目所使用的Python编译器是我们本地安装的编译器三、解决办法3.1安装matplotlib包     安装matplotlib依赖命令如下:python-mpipinstall--usermatplotlib13.2检查项目编译器       检查项目所使用的编译器,这一点尤为重要也很容易被我们忽略,我就是因为这一步卡了一天:我们需要使用的是本机安装的Python编译器,不能使用项目中的编译器,如下图红框所示:
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

QQ|手机版|心飞设计-版权所有:微度网络信息技术服务中心 ( 鲁ICP备17032091号-12 )|网站地图

GMT+8, 2025-1-10 23:06 , Processed in 0.482067 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表