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.
-
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
7 Answers
The problem is caused by CV2 and how __init__.py
does the imports. Just ignore the warnings the program will work all the same, or you can do an import with an alias like:
import cv2.cv2 as cv2
If you have a warning on it press Alt+Enter to install and fix it. Now you will have the code completion and no other warnings (about that) on the project.
-
18`import cv2.cv2 as cv2` gives `ImportError: Bindings generation error. Submodule name should always start with a parent module name. Parent name: cv2.cv2. Submodule name: cv2` – Gulzar Jul 11 '22 at 13:03
Switching to an older version of opencv solved this problem for me.
Apparently pycharm sometime breaks depending on the version of opencv. For me, the newest version was, 4.6.X unstalling and installing 4.5.X did the trick.

- 101
- 1
- 3
-
Sad but that's how I got it working. https://github.com/opencv/opencv/issues/20997. PyCharm should really do something about it. – Philippe Remy Mar 07 '23 at 03:41
I use python 3.10 and my newest version for opencv is 4.6.0.66 ,by changing opencv version to 4.5.5.62 and with an alias: import cv2.cv2 as cv2 my problem has solved.

- 81
- 1
- 5
I installed version 4.5.5.64 and imported with an alias. import cv2.cv2 as cvv2

- 11
- 1
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 27 '22 at 17:38
I was using Python 3.10.2288.0 and OpenCV 1.6.0.66. I resolved the issue by rolling back the OpenCV version to 4.5.5.62.

- 11
- 2
This worked for me-
pip install --force-reinstall --no-cache -U opencv-python==4.5.5.62

- 29,388
- 11
- 94
- 103