Solve the problem "No module named 'cv2' " in python

When I try to import 'cv2' in python, an error arise saying "No module named 'cv2'. I have encountered this problem several times and it's easy to solve it. You can install "opencv-contrib-python" module to solve it. Below are some official descriptions about this module.


Wrapper package for OpenCV python bindings.

Unofficial OpenCV packages for Python with contrib modules.

Note: the usage of opencv-contrib-python might be restricted in some countries since the contrib package contains somepatented algorithms/non-free modules.

If you are looking for a version without the contrib modules, please install opencv-python instead.

The packages contain pre-compiled OpenCV binary with Python bindings. This enables super fast (usually < 10 seconds) OpenCVinstallation for Python.

If you need only OpenCV Python bindings, no separate OpenCV installation is required.

IMPORTANT NOTE

MacOS and Linux wheels do not support video related functionality (not compiled with FFmpeg).

Installation and Usage

  1. If you have previous/other version of OpenCV installed (e.g. cv2 module in the root of Python’s site-packages), remove it before installation to avoid conflicts.
  • To further avoid conflicts and to make development easier, Python’s virtual environments are highly recommended for development purposes.
  1. If you have an existing opencv-python installation, run pip uninstall opencv-python
  2. Install this package:

pip install opencv-contrib-python

  1. Import the package:

import cv2

For more details, please refer to contrib-opencv-python
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值