Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot debug Python modules via launch.vs.json #7675

Closed
vsfeedback opened this issue Jul 12, 2023 · 1 comment
Closed

Cannot debug Python modules via launch.vs.json #7675

vsfeedback opened this issue Jul 12, 2023 · 1 comment

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Visual Studio provides a way to debug Python programs, but fails to launch modules properly, so relative imports are failing. Consider this script (see attached project for a full example):

import sys

from ..util.abc import ABC      # requires -m mymod.app.app to run

def main() -> int:
    abc = ABC("ABC")

    print(f"abc: {str(abc)} args: {sys.argv}")

    return 0

if __name__ == "__main__":
    sys.exit(main())

This module can be debugged via VS Code using this launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "mymod.app.app",
            "justMyCode": true
        }
    ]
}

However, Visual Studio provides no way to specify module debugging in launch.vs.json, so from ..util.abc import ABC always fails to import another module from the same package because the import uses a relative path, which requires app to have a top-level Python module.

Using "interpreterArguments": "-m mymod.app.app" just runs the module and fails to attach a debugger to app.py because all debugpy arguments are added after -m, so they are ignored.

module-test.zip


Original Comments

Feedback Bot on 6/29/2023, 06:19 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@StellaHuang95
Copy link
Contributor

Thanks for the issue. Moving this issue to discussion as an enhancement request for comments and upvotes.

@microsoft microsoft locked and limited conversation to collaborators Jul 12, 2023
@StellaHuang95 StellaHuang95 converted this issue into discussion #7676 Jul 12, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants