iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >numpy与python版本不匹配-ImportError: Unable to import required dependencies: numpy
  • 553
分享到

numpy与python版本不匹配-ImportError: Unable to import required dependencies: numpy

numpypython开发语言 2023-09-17 09:09:08 553人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

问题 你在运行python代码的时候,是否遇到过下面这种错误 ImportError: Unable to import required dependencies:numpy: IMPORTANT:

问题

你在运行python代码的时候,是否遇到过下面这种错误

ImportError: Unable to import required dependencies:numpy: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!Importing the numpy C-extensions failed. This error can happen formany reasons, often due to issues with your setup or how NumPy wasinstalled.We have compiled some common reasons and troubleshooting tips at:    https://numpy.org/devdocs/user/troubleshooting-importerror.htmlPlease note and check the following:  * The Python version is: python3.7 from "C:\Users\MSI-NB\.conda\envs\python37\python.exe"  * The NumPy version is: "1.21.6"and make sure that they are the versions you expect.Please carefully study the documentation linked above for further help.Original error was: DLL load failed: 找不到指定的模块。

如上信息所示,我的python版本是3.7,Numpy版本是1.21.6,他们的版本不匹配,导致运行报错。

解决方法

通过安装对应的版本号,python3.7对应的是numpy1.19.5,直接按照对应版本即可。
如果你使用的pip,只需要执行

pip uninstall numpypip install numpy==1.19.5

如果你使用的是conda,需要执行

conda uninstall numpyconda install numpy==1.19.5

那么如何知道他们的对应关系呢,这个网站你一定要收藏
Https://www.lfd.uci.edu/~Gohlke/pythonlibs/
在这里插入图片描述
在这里,你能够看到所有python库和python版本的对应关系。以pandas为例,如下图所示,cp后面指的就是python版本,cp39就是python3.9,那么它对应的pandas版本就是pandas==1.3.5
在这里插入图片描述
如果依然无法解决你的问题,可以尝试安装numpy-base

conda install -c anaconda numpy-base

如果依旧没有解决,你可以看下你的pip下和conda下是不是都有Numpy,通过执行pip list 和conda list,如果是的话,需要将pip种的删除,pip uninstall numpy.

不过的执行后,又报了另外一个错误,

~\.conda\envs\python37\lib\site-packages\pandas\_typing.py in      82 # array-like     83 ---> 84 ArrayLike = UNIOn["ExtensionArray", np.ndarray]     85 AnyArrayLike = Union[ArrayLike, "Index", "Series"]     86 AttributeError: module 'numpy' has no attribute 'ndarray'

这个报错是因为numpy和panda版本不匹配导致的,需要卸载后重新安装,注意,需要先安装numpy,再安装pandas

来源地址:https://blog.csdn.net/jingyoushui/article/details/131617859

--结束END--

本文标题: numpy与python版本不匹配-ImportError: Unable to import required dependencies: numpy

本文链接: https://www.lsjlt.com/news/410929.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作