Configure VS code to understand ros package imports

asked 2023-07-21 08:27:53 -0500

infraviored gravatar image

I am importing lots of packages into other packages. I can execute the imported packages without any problems. But the linking in VS code is not working, Pylance is giving me import errors.

I have a workspace called happyspace. The path to the dist-packages is

/home/flo/happyspace/devel/lib/python3/dist-packages

so I added this to my workspace config:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "editor.fontSize": 15,
        "[python]": {
            "editor.defaultFormatter": "ms-python.autopep8"
        },
        "python.formatting.provider": "none",
        "editor.defaultFormatter": null,
        "python.autoComplete.extraPaths": [
            "/home/flo/happyspace/devel/lib/python3/dist-packages",
            "/opt/ros/noetic/lib/python3/dist-packages"
        ],
        "python.analysis.extraPaths": [
            "/home/flo/happyspace/devel/lib/python3/dist-packages",
            "/opt/ros/noetic/lib/python3/dist-packages"
        ]
    }
}

however, upon imports of one package into another, like for example in my in execute_poses_record.py located in

/home/flo/happyspace/src/fmp_tools/src/fmp_tools/execute_poses_record.py

the line

from fmp_tracepen_node.tracepen_node import TracepenNode

gets the error

Import "fmp_tracepen_node.tracepen_node" could not be resolvedPylancereportMissingImports (module) fmp_tracepen_node

while the file to be imported sits in

/home/flo/happyspace/src/fmp_tracepen_node/src/fmp_tracepen_node/tracepen_node.py

What am I doing wrong?

help is greatly appreciated.

edit retag flag offensive close merge delete

Comments

https://answers.ros.org/question/3827...

Related, but not problem-solving for me.

infraviored gravatar image infraviored  ( 2023-07-24 10:24:40 -0500 )edit

I need help. No advice?

infraviored gravatar image infraviored  ( 2023-07-27 13:45:42 -0500 )edit