I'm trying to familiarize myself with the pydrake
library, which is python bindings around a C library called Drake. I installed the library with pip
inside a virtualenv
and am tinkering with it in VSCode. Unfortunately, I can't get code completion for most symbols, which makes it kind of difficult to know:
- What symbols are in each (sub)module
- What args each function takes and returns
My current work flow has been to look through the C /Python API online, which works but is a little cumbersome.
I tried to edit the settings.json
with:
"python.autoComplete.extraPaths": [
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/",
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/lib/",
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/common/",
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/manipulation/"
...
],
"python.analysis.extraPaths": [
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/",
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/lib/",
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/common/",
"${workspaceFolder}/venv/lib/python3.8/site-packages/pydrake/manipulation/"
...
]
That was based on comments from https://github.com/microsoft/vscode-python/issues/7736#issuecomment-537620794, since those folders contain the cpython .so
files. That didn't work for me.
Is it possible to get intellisense for this?
Other details in case they matter:
- Ubuntu 20.04 5.15.0-48-generic
- VSCode version: 1.71.2 74b1f979648cc44d385a2286793c226e611f59e7
- Python extension version: v2022.14.0
- drake version:
drake==1.8.0
CodePudding user response:
See https://github.com/RobotLocomotion/drake/issues/16987. It's a work in progress.
As of today (2022-Sep-26), the pydrake
library does not yet provide *.pyi
files for VSCode autocomplete.
In general you can try to run tools like stubgen
to produce the *.pyi
files automatically from the native *.so
files and then use those for autocomplete, but for pydrake
those tools don't understand our templates yet, so the results are not terribly useful.
In the meantime, a Jupyter-based editor (e.g., Deepnote) does generally autocomplete the native code correctly. It's only VSCode's virus-protection posture of not loading native code for auto-complete that's getting in your way.