I am trying to debug python code in vscode using a launch config that asks for command line arguments.
My script is located here:
C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python\my_script.py
and my test input file is here:
"C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\temp\test.txt"
The vscode launch.json is:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": "${command:pickArgs}"
}
]
}
When I press F5 or click 'Run > Start Debugging', I get this popup in which I paste the fully qualified filename:

after which the debug terminal below spits out the following:
PS C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python> c:; cd 'c:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python'; c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\python.exe c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher 50410 -- C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python\my_script.py "C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\temp\test.txt"
Traceback (most recent call last):
File "c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy\__main__.py", line 71, in <module>
cli.main()
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 508, in main
run()
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 358, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 309, in run_path
code, fname = _get_code_from_file(run_name, path_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 278, in _get_code_from_file
with io_open_code(decoded_path) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\USERNAME\\FolderName'
PS C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python>
I assumed it was due to the fact that my test file was in a path with spaces, so I moved it and ran the script again so the argument no longer contained spaces:

But I still got a similar error, as shown below:
PS C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python> c:; cd 'c:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python'; c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\python.exe c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher 53983 -- C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python\my_script.py "C:\Users\USERNAME\Downloads\test.txt"
Traceback (most recent call last):
File "c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy\__main__.py", line 71, in <module>
cli.main()
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 508, in main
run()
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 358, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 309, in run_path
code, fname = _get_code_from_file(run_name, path_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 278, in _get_code_from_file
with io_open_code(decoded_path) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\USERNAME\\FolderName'
PS C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python>
Looking more closely, it is now becoming apparent to me that the issue might be with the launcher, since I see in the output:

Trying to trace execution backwards, I think it might be braking here in cli.py:

because it does not appear to handle fully qualified paths with spaces. That is, when it executes, it has to call the script itself as an argument, and it appears to be the script argument that is not getting correctly wrapped in double quotes as it needs to be.
I am not 100% sure where exactly this should be fixed...
c:; cd 'c:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python'; c:\Users\USERNAME\AppData\Local\Programs\Python\Python312\python.exe c:\Users\USERNAME\.vscode\extensions\ms-python.debugpy-2025.14.1-win32-x64\bundled\libs\debugpy\launcher 53983 -- C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python\my_script.py "C:\Users\USERNAME\Downloads\test.txt"as the script name here-- C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\Python\my_script.pyisn't quoted properly. Python is not at fault here."program": "${file}",=>"program": "\"${file}\"",in the json file? worth trying