7

I have opencv-python installed and the .pyd file is added in the site-packages and the DLLs. The code works with images. When I want to read, show, write an image it works. But I get a warning that the functions' references cannot be found in init.py . Due to this, I can not use the auto-complete feature. Could someone help me out? I am using opencv 3.4.0 and python 3.6.4 in pycharm. I downloaded opencv via pip in the command prompt.

prog
  • 103
  • 1
  • 5
  • The last time I used opencv, it was not compatible with python 3.x, but instead 2.x (2.6 I believe). Unless they have made it compatible with 3.6, you may run into errors down the road (if not now) – A.B. Feb 13 '18 at 17:47
  • I think it is compatible now, I have used the customize installation and it is working with images. the problem is with the autocomplete and the warnings – prog Feb 13 '18 at 18:08
  • Hi sir! Did you solve the problem, I also have the same error with PyCharm? Thanks! – Bahramdun Adil May 29 '19 at 06:00

2 Answers2

27

The problem is caused by CV2 and how init.py does the imports. Just ignore the warnings the app will work the same. Or you can do an import with alias like

import cv2.cv2 as cv2

If you have a warning on it press Alt+Return to install and fix it. Now you will have the autocomplete and no other warnings (about that) on the project.

Jox
  • 327
  • 1
  • 5
  • 13
8

Import cv2 as follows:

from cv2 import cv2
Edwin Acevedo
  • 89
  • 1
  • 3