79295168

Date: 2024-12-19 17:48:09
Score: 1.5
Natty:
Report link

Same as what mentioned in this answer by Scott.

I was looking for how to solve this issue of relative paths. This article showed to me how it is done. https://k0nze.dev/posts/python-relative-imports-vscode/

So you need to use the "env" key in launch.json to add your workspace directory to the PYTHONPATH and voila!

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "env": {"PYTHONPATH": "${workspaceFolder}"}
        }
    ]
}
Reasons:
  • Blacklisted phrase (1): This article
  • Blacklisted phrase (1): how to solve
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Emad Goahri