'How do I solve this error with OpenCV in python? [duplicate]

I'm working in a python program using OpenCV and I get an error saying that the module cv2 hasn't been found.

When I try to upgrade pip this appears:

WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)

I cheked the modules avaliable in the python folder and opencv appears.



Solution 1:[1]

You would need to go to c:\python310\lib\site-packages and :

  1. delete any package that starts with 'ip' as it says in your Warning
  2. delete other packages mentioned apart from 'ip' in the warning(if any)
  3. delete any package that starts with '~'

This should help get rid of the invalid dists.
After that you can re-install any of the deleted packages if needed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ayush