--- tags: debug, google colab --- # module 'cv2.cv2' has no attribute 'xxx' This may happen when opencv is not correctly installed. So we need to first uninstall opencv and then reinstalling it. ## Uninstall Both lines need to be done. ```UNIX pip uninstall opencv-python pip uninstall opencv-contrib-python ``` ## Install Both lines need to be done. ```UNIX pip install opencv-python pip install opencv-contrib-python ``` ## Error When installing, be sure to check if there are any error messages. For example, if you have an error like ![](https://i.imgur.com/pp0OQy3.png) > ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. albumentations 0.1.12 requires imgaug<0.2.7,>=0.2.5, but you have imgaug 0.2.9 which is incompatible. We should reinstall imgaug or whatever source that is causing the conflict so that it matches the correct version. Take this message as an example, the 0.2.5 or 0.2.6 version of "imgaug" should be installed. ```UNIX pip uninstall imgaug pip install imgaug==0.2.5 ``` After this step, we need to redo the steps of uninstalling and installing opencv. This time, there shouldn't be any errors. Remember to restart the kernal and reimport opencv before using it.