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
>>>
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值