6

Okay, so after installing OpenCV and Numpy both on my machine, and also enabling and installing them again in Pycharm, I still get the error when writing the OpenCV code (no autocomplete). This is the erro:

Cannot find reference 'imshow' in '__init__.py'

Here is how it looks:

enter image description here

When I run it, the code works, but it is really annoying that Pycharm doesn't recognize it. I tried all the solutions I could come up with, but it still persists. I uninstalled and then reinstalled everything (multiple times), set up different interpreters, but the issue still persists. I also tried installing different versions of both Python and OpenCV, but nothing works. Any ideas?

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
arbiter
  • 421
  • 7
  • 29
  • 1
    It seems OK, there is no quibble line underneath so I guess it recognizes it. – David Dec 27 '20 at 10:12
  • PyCharm normally creates VirtulaEnvironments for Python. Make sure OpenCV is in your VirtualEnvironment or try using the system interpreter. – wuerfelfreak Dec 27 '20 at 11:48
  • Unfortunately neither works, I added OpenCV file to the venv/scripts and the issue still shows. Then I tried with system interpreter to no avail. – arbiter Dec 27 '20 at 11:58
  • pycharm and opencv is a common issue. please look for previously answered questions. here's a previous question https://stackoverflow.com/questions/51632134/pycharm-can-not-install-opencv – Christoph Rackwitz Dec 27 '20 at 12:22
  • 1
    as Christoph said, this is a well-know issue... there are some tricks in the official [YouTrack thread](https://youtrack.jetbrains.com/issue/PY-35691), but unfortunately they are inconsistent. – baggiponte Mar 15 '22 at 15:37
  • 1
    @baggiponte FWIW, workaround #1 in that thread worked for me, so thanks for sharing the link ! – Soltius Jul 05 '22 at 14:38
  • I am using the latest PyCharm version (professional tbh, since I have a student license) and haven't had this issue in a while. Still fails to recognize the top `import cv2` but that's because of an unrelated reason (I am using poetry) – baggiponte Jul 07 '22 at 09:59

0 Answers0