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:
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:
drake==1.8.0
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.