module 'cv2' has no attribute 'imread'

  • Python
  • OpenCV

You may see

AttributeError: module 'cv2' has no attribute 'imread'
AttributeError: module 'cv2' has no attribute 'face'

Why it happens

  • Your file is named cv2.py.
  • The part you need is in opencv-contrib-python.

How to fix it

  1. Rename your file, and delete the __pycache__ folder.
  2. For extras such as cv2.face install only opencv-contrib-python.

It worked if: print(cv2.__file__) shows site-packages.

Seen in a real run (some lines are close variants of it). Produced with Python 3.13 and OpenCV 5.1 on Windows.

Didn't help? Search another error or ask us.