stereolabs / zed-python-api

Python API for the ZED SDK
https://www.stereolabs.com/docs/app-development/python/install/
MIT License
209 stars 95 forks source link

No code completion (Intellisense) for pyzed.sl #199

Closed silegc-xguard closed 2 years ago

silegc-xguard commented 2 years ago

Preliminary Checks

Description

Hi everyone,

I installed the Python API through the get_python_api.py script. While I can compile/run every example, I can't get code completion (Intellisense) to work. I'm running Python 3.8.5 with Anaconda in VsCode.

Is there a way to enable it ? It would be a very useful for development instead of always needing to refer to the online API documentation.

Thanks, Simon

Steps to Reproduce

  1. Install the API using the get_python_api.py script
  2. Try to use code completion in VsCode

Expected Result

Code completion should work

Actual Result

No code completion results appear at any level of the API

ZED Camera model

ZED2i

Environment

OS: Windows 10
ZED SDK: v3.6.1

Anything else?

No response

haavarpb commented 2 years ago

Hi, I'll chip in with my solution here since I just had this problem myself. Please correct me if I am wrong, but I think this is due to the API being distributed as a .pyd-file. The VSCode intellisense is not able to read those directly, since its a binary file, more specifically a DLL. To get intellisense to work, I used the genstub tool to decompile the .pyd files present in the pyzed api and it created .pyi-files for my intellisense to read. Just run the genstub tool (I think I added -m-switch for module) and point it to the pyzed api folder. Voilá. Hope it helps!

silegc-xguard commented 2 years ago

Thanks ! I got it to work that way.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days

junsukha commented 1 year ago

@haavarpb @silegc-xguard Hello, thanks for sharing the question and tip. I'm following the guide but I don't understand the last part "point it to the pyzed api folder". Could you explain what that means? or. I guess I genstubbed a wrong file. Now I ran genstub on .pyb file in my pyzed, stubgen -m sl.cp38-win_amd64 I get sl.cp38-win_amd64: Failed to import, skipping with error: No module named 'sl.cp38-win_amd64'; 'sl' is not a package How did you resolve this one?

kavehsgh commented 3 months ago

Here is a very easy solution that I posted on the Stereolabs community website. Link