OpenCV isn't working in PyCharm

I think my issue is isolated to pycharm itself. When I run the script from the command prompt the script works just fine. When I run the script from pycharm itself I get this error code: AttributeError: module 'cv2' has no attribute 'waitKey'

And, when I use…
import cv2
to see what the context menu shows, this is what I get…
Screenshot 2023-03-27 230626
I’m thinking that pycharm is using it’s own installation of python outside of what is already installed on my computer, and this is where the error is coming from, a slimmed down version of opencv, or some other module with the same name.

Has anyone ever had this issue?

O’Yeah, so you know, I’m taking the course 100 Days of Code: The Complete Python Pro Bootcamp for 2023 and she is using pycharm, and I have zero experience whit pycharm.

for assistance with PyCharm, please find a forum specific to pycharm.

Wow, that was dismissive.

I came across the same issue. I think they broke opencv on their last update because I had been using it fine in PyCharm and it magically stopped working. Looks like the OpenCV guys on Github were more receptive to helping solve the issue.

In PyCharm, click File - Settings - Project: - Python Interpreter

Find opencv-python in the list and click on it to highlight, followed by the minus (-) sign at the top of the list to remove it. Give it a few seconds to uninstall before hitting the plus (+) sign. Find opencv-python line and click it. Before you install it again, click the “Specify Version” checkbox and select “” as the version and click install. That’s what worked for me.

1 Like