-
Notifications
You must be signed in to change notification settings - Fork 767
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
No intellisense for cv2 (opencv) #138
Comments
Similarly to #103: The We currently don't have a scraper that will create type stubs for compiled modules. Therefore, for now, a fix would be for |
Maybe we can manually use
|
Well, does the Microsoft have the plan to fix it? |
I have the same issue as deTrident, but unfortunately reverting back to Jedi did not solve my problem. EDIT: |
I'm curious, how did the old language server do it (the |
It did have a scraper which ran on libraries and only libraries, but doing so is iffy for a multitude of reasons, running arbitrary code being one of them. Note that Pylance (being a type checker under the hood) doesn't play extremely nicely with stubs that come out of the scraper, as the scraper almost never gets any types (and often signatures) correct. MPLS was not a type checker and internally had many assumptions which would have never made it a type checker, so adding more inaccuracy to the mix wasn't fatal. We haven't ruled out a scraper, but there are other paths we can take that we think will produce a better experience than trying to add it back at this stage. |
Any updates? I saw it was added 'compiled' tag |
This problem seems related with Pylance server. Uninstalling it and switching back to default Jedi can solve it. |
This is the repo for pylance, so I assume the goal of this "issue" is to fix cv2 support on Pylance. Disabling/uninstalling pylance is a short term workaround but not really relevant here. |
Does the latest version (2020.11.2) really fixed this? (It said that it's solved in the first bullet here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020112-18-november-2020 ) |
I tried 2020.11.2 and even 2020.11.3-pre.1 and couldn't get it to work. I do see the included stub: But I'm not sure how to get pylance to use it. Manually copying the cv2.pyi file into |
On 2020.11.2, when I do:
I get completions for everything in the compiled module (which has a lot), including I'm testing on Windows. This is OS sensitive code, which OS are you on where it's not giving on completions on cv2? |
Oh, also note that you will need to have |
I'm on windows 10, on Python 3.7.7 (venv) with the following installed: and this is what I see: https://i.imgur.com/LS41Y0K.png As mentioned above, moving the stub to stubPath works, the module goes green and completion works.
|
@EhsanKia have you tried getting completions on a clean project with just a new opencv-python? In my case I tried with opencv-python==4.4.0.44. As Hugues, mentioned above, I do get completions. I'd also recommend the latest version of Pylance. Please let me know if you still don't receive completions |
Closing issue. Please reopen if necessary. |
I'm using latest version of pylance (v2021.1.4-pre.1) and (opencv 4.5.1) and remote containers. The autocomplete doesn't work for me. |
I found the problem. My opencv was installed through
So I uninstalled and installed it without sudo by using
Things are working now. |
Pylance uses the environment selected by the Python extension, and then calls that interpreter to get search paths (so we match the intrpreter). If you enable Pylance's trace logging, you should see those paths printed out. Did you see that first directory in the logs at all? I'm surprised pip as root would be installing there, as opposed to say |
@jakebailey Thank you for the quick reply. Packages installed through dpkg/apt: How can I enable the pylance tracing? |
See https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue, but I would recommend filing a new issue as this seems unrelated to the original issue. We would certainly support those directories, and the trace logs should show the paths in use. |
This only happens with opencv. I have tensorflow in the same folder The issue is easily reproducable. The path is indeed in the interpreter. Something different for opencv package that should not be in ‘/bin/local’ |
|
To make the stub file quiclkly:
|
here are some work in progress stubs |
Make sure to change the name of generated stub file from |
parsa-ra - thank god for your comment |
Works fine for PyCharm 2022.3.1 and Intellij. Unfortunately there is no other solution than this.
To avoid all these steps. Just copy the file |
Even without a stub file that produces detailed signatures with types it seems like pylance should be capable of looking up method and attribute names, which would likely solve most of what people are looking for. Intellisense is especially nice for a large package like this just to help you find the right names. Clearly the stub generation is problematic, or this could have happened years ago. |
the latest opencv package should be shipping with its own stubs. Is that not working? please create a new issue then. see #4838 (comment) |
Prompt there is a bug,cannot reach the method of imread()
Replace back to python language server, everything is ok
The text was updated successfully, but these errors were encountered: