2

I´m using PyCharm 2021.2 Professional edition and I have installed opencv-python with:

pip install opencv-python

However, the IDE keeps giving me the following warning when I try to use cv2 package:

Cannot find reference 'resize' in 'init.py'

Here I gave the example of the resize function, but it´s happening for every function in cv2 package. Although the code runs with no errors, I can´t use the auto complete feature, which is a bit annoying. I found an answer here that might help. The guy says to use:

import cv2.cv2 as cv2

However this is not working for me. Im getting the following error:

ERROR: No matching distribution found for cv2

That´s because there is no package named cv2 inside opencv. Does anyone knows how to solve this problem? Is it a PyCharm's issue?

UPDATE
Here is the output of the command pip show opencv-python :

Name: opencv-python
Version: 4.5.3.56
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/skvark/opencv-python
Author: None
Author-email: None
License: MIT
Location: z:\appdata\python\lib\site-packages
Requires: numpy
Required-by:

  • Does this answer your question? [PyCharm doesn't recognise installed module](https://stackoverflow.com/questions/31235376/pycharm-doesnt-recognise-installed-module) – ti7 Aug 05 '21 at 16:22
  • Unfortunately this doesn´t solve my problem. In my case, Python recognizes that the module is installed and runs the code with no error, but I can´t get auto complete feature because it can't find a reference in init.py – Daniel Aben-Athar Bemerguy Aug 05 '21 at 16:52
  • There is nothing wrong with your installation. If the function is implemented in C or C++ then PyCharm won't be able to resolve it. PyCharm does static analysis. If it is necessary to execute the code for the function to exist then PyCharm won't see it. The PyCharm documentation for this warning specifically says that. Just ignore the warning, or silence it. – BoarGules Aug 07 '21 at 07:55
  • Did you find a solution to this? – S P Sharan Sep 27 '21 at 16:34
  • Actually, I didn´t. If you have a solution please share. – Daniel Aben-Athar Bemerguy Sep 28 '21 at 03:18

1 Answers1

1

can you share the output of the command pip show opencv-python if the output is some thing like this

Name: opencv-python
Version: 4.5.1.48
Summary: Wrapper package for OpenCV python bindings.
Home-page: https://github.com/skvark/opencv-python
Author: None
Author-email: None
License: MIT
Location: c:\users\{username}\appdata\local\programs\python\python37\lib\sitepackages
Requires: numpy
Required-by:

then their is some problem with opencv's __init__.py file

can you please share the output

Thank you

by your output, it is clear that pip has properly installed cv2 on your machine

can you now share the output of

python -c "import cv2"

this is to check whether there is a problem with python or pycharam