ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I have tried all the mentioned solutions but none of them worked for me, here is what I ended up with.

My goal is to get Pylance (the better vscode language server) to recognize my ros packages and not default to the devel/... generated file. For this the only important thing is for the package directory (catkin_ws/src/python_package/src/) to be present after the generated (catkin_ws/devel/lib/python3/dist-packages) one in the PYTHONPATH global variable. For some reason pylance (and pyright) always pick the last valid import path when analysing an import. This way custom package code points to the implementation and generated msgs still point to the generated code.

TL;DR

first source devel/setup.bash then add src/python_package/src to pythonpath