import cv2错误:ImportError: numpy.core.multiarray failed to import

  • 系统环境:Windows10
  • Python环境:Anaconda + Python3.6.3
  • OpenCV:3.4.3
    安装完OpenCV库之后,导入cv2时出现numpy.core.multiarray failed to import问题:
(D:\Users\XXX\Anaconda3) C:\Users\XXX>python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import

问题原因: opencv3版本与numpy的版本不匹配,可以尝试更新numpy的版本试试.
解决办法:
在控制台窗口中输入:

pip install -U numpy

出现以下信息表示降级完成.

(D:\Users\XXX\Anaconda3) C:\Users\XXX>pip install -U numpy
Collecting numpy
  Downloading https://files.pythonhosted.org/packages/51/70/7096a735b27359dbc0c380b23b9c9bd05fea62233f95849c43a6b02c5f40/numpy-1.15.4-cp36-none-win_amd64.whl (13.5MB)
    100% |████████████████████████████████| 13.5MB 27kB/s
Installing collected packages: numpy
  Found existing installation: numpy 1.12.0
    Uninstalling numpy-1.12.0:
      Successfully uninstalled numpy-1.12.0
Successfully installed numpy-1.15.4

再次测试,import cv2成功!

(D:\Users\XXX\Anaconda3) C:\Users\XXX>python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
  • 8
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
这些错误信息表明在导入numpy库时出现了问题,具体是numpy的某些模块无法正确导入。 这种错误通常是由于numpy库没有正确安装或版本不兼容导致的。 要解决这个问题,你可以尝试以下几个步骤: 1. 首先,请确保你已经正确安装了numpy库。你可以使用pip命令来进行安装,例如在命令行中运行:`pip install numpy`。 2. 如果你已经安装了numpy库,可以尝试升级到最新版本。可以使用pip来更新numpy库,例如在命令行中运行:`pip install --upgrade numpy`。 3. 如果你的操作系统是Windows,还可以尝试重新安装Microsoft Visual C++ Redistributable包。你可以从Microsoft官方网站下载并安装适合你操作系统的包。 4. 如果上述步骤都无法解决问题,你可以考虑卸载并重新安装Python解释器以及numpy库。确保使用最新的Python版本,并且按照官方文档的指示正确安装numpy库。 希望上述解决方法能够帮助你解决问题。如果问题仍然存在,请提供更多详细的错误信息和操作环境,以便我们能够更好地帮助你解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ImportError: numpy.core._multiarray_umath failed to import的解决方案](https://blog.csdn.net/a1456123a/article/details/115375952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Python 常见问题 之 from .cv2 import * ImportError: numpy.core.multiarray failed to import](https://blog.csdn.net/u014361280/article/details/109921586)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值