New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyCharm cannot find cv2 references with the most recent version #20997
Comments
duplicate of opencv/opencv-python#574 |
Related: opencv/opencv-python#570 |
This is still a problem in version 4.5.5.62 |
It has been fixed in opencv/opencv-python#579. I've tried to reproduce using the latest version - 4.5.5.62, but it works on my side. I've even tried to clean cache. My steps to reproduce:
Tried the same using File -> Invalidate Caches / Restart... in PyCharm. @bvitaz-ck, could you tell me what I am doing wrong or different? |
After some experimentation, opencv-python appears to work, but opencv-contrib-python does not. |
I've tried to do the same with |
It looks like PyCharm builds index for autocomplete for the first several seconds. |
Same in visual studio code : pylance cant see the opencv-contrib modules (some are seen because of the stubgen) |
PyCharm was working for me with |
Confirmed, same here. IDE info:
|
As above, |
I can confirm this works absolutely brilliantly with opencv-contrib-python. Running the above mentioned command fixed it immediately after Pycharm was done rebuilding skeletons and Indexing. |
With all due respect, downgrading is a work-around, not a solution - and certainly not long term. |
It's not a considerable issue when you take into account the version difference. I have had similar reference issues with other modules in PyCharm which has led me to abandon PyCharm entirely. |
Hi @18iteration if the issue is PyCharm related then totally agreed PyCharm should provide a fix. However considering the previous version had no issue in PyCharm, are you sure this is the case? I've not seen this issue before with other packages in PyCharm, and I've used a LOT of packages. Hopefully this will be fixed in the next release. |
This seems a reasonable solution, thank you very much for this @bentennysonyoung! Just a comment on the screenshots - the top image shows The bottom image shows after adding the cv2 path: |
will this issue ever be fixed? |
Install the latest Pycharm and downgrade the CV lib to 4.5.X. Something like that should work:
|
This worked for me: |
As an alternate to adding the |
Thank you. I will give it a try. |
im not able to find cv2 path in my ubuntu system |
Also "Cannot fine declaration" with latest (for me thats v4.7.0.72) I can see some binary symbols e.g. in site-packages/cv2/cv2.abi3.so, but thats not useful to build skeletons When things are workig you'll see files like this: ~/Library/Caches/JetBrains/PyCharm2023.1/python_stubs/.../cv2 by generator 1.147""" OpenCV Python binary extension loader """ Happy to help fix this, if there are ideas, maybe there was a PyCharm change to 'generator'? |
worked for me! Thanks a ton 🙏 |
Detailed description
PyCharm gives the following warning everywhere where cv2.* is used:
cannot find reference <function name> in __init__.py | __init__.py
I'm importing cv2 as:
import cv2
the issue arose with the update to the 4.5.4.58 vesion
Issue submission checklist
forum.opencv.org, Stack Overflow, etc and have not found solution
any ideas how to overcome this? Thanks!
Best,
Alexey
The text was updated successfully, but these errors were encountered: