I need to enable debugging in VS Code to debug a Python file but, due to the specific nature of my .py file, I need to do this not from the project directory, but from a directory one level above my project directory. And since the file I need to run uses static imports, I need to run the file as a module, meaning that when debugging, VS Code uses the -m parameter and the module name, which looks like this: project_name_folder.folder1.main
I haven't found a working way to do this yet. I tried creating my own launch.json file inside the .vscode directory with the following contents:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Module",
"type": "debugpy",
"request": "launch",
"module": "project_folder.folder1.main",
"cwd": "${workspaceFolder}/..",
"console": "integratedTerminal"
}
]
}
But this configuration produces an error:
E+00000.060: Error determining module path for sys.argv
Traceback (most recent call last):
File "c:\Users\User\.vscode\extensions\ms-python.debugpy-2025.18.0-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 370, in run_module
spec = None if options.target is None else find_spec(options.target)
~~~~~~~~~^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\importlib\util.py", line 91, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'project_folder.main'
Stack where logged:
File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
File "c:\Users\User\.vscode\extensions\ms-python.debugpy-2025.18.0-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy\__main__.py", line 71, in <module>
cli.main()
File "c:\Users\User\.vscode\extensions\ms-python.debugpy-2025.18.0-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 508, in main
run()
File "c:\Users\User\.vscode\extensions\ms-python.debugpy-2025.18.0-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 374, in run_module
log.swallow_exception("Error determining module path for sys.argv")
File "c:\Users\User\.vscode\extensions\ms-python.debugpy-2025.18.0-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\common\log.py", line 215, in swallow_exception
_exception(format_string, *args, **kwargs)
c:\Users\User\Documents\project_folder\.venv\Scripts\python.exe: Error while finding module specification for 'project_folder.folder1.main' (ModuleNotFoundError: No module named 'project_folder.folder1')
How to fix this error?
project_name_folder.folder1.mainbut in config you have"project_folder.folder1.main",- it is different value. OR maybe you should use${workspaceFolder}to create correct path.