Module 'cv2.cv2' has no attribute 'ximgproc'

pip install opencv-contrib-python --upgrade

works for me.


As mentioned in the OpenCV pypi web page:

  1. If you have previous version of OpenCV installed remove it before installation to avoid conflicts.
  2. There are 4 different opencv packages: opencv-python, opencv-contrib-python, opencv-python-headless, opencv-contrib-python-headless.
  3. You can only install one. Multiple opencv packages are incompatible.

When asking my question, I had 2 opencv packages. Therefore I first removed the two existing packages:

$ pip uninstall opencv-contrib-python opencv-python

And then, I installed only one package:

$ pip install opencv-contrib-python

Finally, the installation worked.


This should solve the issue, if you have pip installed. I found pip installer to be better than conda installer in general.

pip install opencv-contrib-python