My Python project folder structure is as follow:
.python_practice
|--lib
|--lib.py
|--__init__.py
|--practice1
|--my_module.py
|--__init__.py
|--__init__.py
My launch configuration is
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "practice1.my_module",
"console": "integratedTerminal"
},
In my_module.py
from lib.lib import util_func
When I try to debug using VScode I get an error: "No module named practice1.my_module"
But when I run it with the following command it works fine
python -m practice1.my_module
How could I debug my code so that the relative import work?
Any help will be appreciated, thank you.
You can also start the debugger by clicking on the down-arrow next to the run button on the editor, and selecting Debug Python File in Terminal. The debugger will stop at the first line of the file breakpoint. The current line is indicated with a yellow arrow in the left margin.
Start by clicking on the debug icon on the left-hand panel of your VSCode. Click on create a launch. json file, which will give you a drop-down of all your currently installed debuggers. By default, a Python debugger is not installed in VSCode.
To end a debugging session in Microsoft Visual Studio, from the Debug menu, choose Stop Debugging.
This is a known bug involving debugging sub-modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With