Description
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.
Original Comments
Feedback Bot on 6/29/2023, 06:19 PM:
(private comment, text removed)
Original Solutions
(no solutions)
Activity
StellaHuang95 commentedon Jul 12, 2023
Thanks for the issue. Moving this issue to discussion as an enhancement request for comments and upvotes.