I have tried different solutions to enable me to debug a python file in my project. Here is my file structure:
project-main
-ns
-examples
and several Python files in examples and ns. Basically, all example files are using ns or other imported modules. I also have a conda environment that I have already activated in vs code terminal. And here is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Module",
"type": "python",
"request": "launch",
"module": "project-main.examples",
}
]
}
I select Start debugging from the Run menu but I keep getting this error:
E+00000.063: Error determining module path for sys.argv
Traceback (most recent call last):
File "c:\Users\myuser\.vscode\extensions\ms-python.python-2023.8.0\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 296, in run_module
spec = find_spec(options.target)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'project-main'
. . .
File "c:\Users\myuser\.vscode\extensions\ms-python.python-2023.8.0\pythonFiles\lib\python\debugpy/..\debugpy\common\log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
C:\Users\myuser\AppData\Local\Programs\Python\Python310\python.exe: Error while finding module specification for 'project-main.examples' (ModuleNotFoundError: No module named 'project-main')
Here is the correct config:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "examples.run_this",
"justMyCode": true
}
]
}
so basically for the module field, I have to enter the name of the subfolder that includes the main running file (run_this) and then the name of the running file.