Robotics StackExchange | Archived questions

Configure VS code to understand ros package imports

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 executeposesrecord.py located in

/home/flo/happyspace/src/fmptools/src/fmptools/executeposesrecord.py

the line

from fmp_tracepen_node.tracepen_node import TracepenNode

gets the error

Import "fmptracepennode.tracepennode" could not be resolvedPylancereportMissingImports (module) fmptracepen_node

while the file to be imported sits in

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

What am I doing wrong?

help is greatly appreciated.

Asked by infraviored on 2023-07-21 08:27:53 UTC

Comments

https://answers.ros.org/question/382798/vscode-rospy-import-error/?answer=417630#post-id-417630

Related, but not problem-solving for me.

Asked by infraviored on 2023-07-24 10:24:40 UTC

I need help. No advice?

Asked by infraviored on 2023-07-27 13:45:42 UTC

Answers