This solution seems to work for a majority of users, but not
all. If you are in this case, see the proposed answer by
Sachin Mohan.
I had the exact same error using yolov5, on Windows 10. Reinstalling the library by typing
pip uninstall opencv-python
then
pip install opencv-python
worked for me.