Description
Type: Bug
Behaviour
Using the auto-generated launch configuration for debugging a Python script, and supplying command line arguments, a script cannot be debugged when python.exe is in a 'C:\Program Files' directory.
The launch script does not handle spaces in the filename of the python executable.
Steps to reproduce:
- Create launch configurations for "Python Debugger: Current File with Arguments", and "Python Debugger: Current File". This should produce the following launch.json
{
// 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}"
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
- Create a python script called test.py containing the following
import sys
if len(sys.argv) > 1:
print(f"Parm 1: ", sys.argv[1])
else:
print("No parameter")
-
Goto the 'Run and Debug' pane and select 'Python Debugger: Current File' from the drop down.
-
Press F5 to run the script. You should see the script being invoked in a similar way to the following.
PS C:\eng\users\clelandd\work\RSA2EA\python\find_ids> c:; cd 'c:\eng\users\clelandd\work\RSA2EA\python\find_ids'; & 'c:\Program Files\Python310_64\python.exe' 'c:\Users\clelandd.vscode\extensions\ms-python.debugpy-2025.6.0-win32-x64\bundled\libs\debugpy\launcher' '34765' '--' 'C:\eng\users\clelandd\work\RSA2EA\python\find_ids\test.py'
No parameter
Script runs.
-
Goto the 'Run and Debug' pane and select 'Python Debugger: Current File with Arguments' from the drop down.
-
Press F5 to run the script. Enter 'Test' into the 'Command Line Arguments' prompt that appears, then press Enter.
-
You should see the script being invoked as follows, and failing to run.
PS C:\eng\users\clelandd\work\RSA2EA\python\find_ids> c:; cd 'c:\eng\users\clelandd\work\RSA2EA\python\find_ids'; c:\Program Files\Python310_64\python.exe c:\Users\clelandd.vscode\extensions\ms-python.debugpy-2025.6.0-win32-x64\bundled\libs\debugpy\launcher 34837 -- C:\eng\users\clelandd\work\RSA2EA\python\find_ids\test.py ${command:pickArgs}
c:\Program: The term 'c:\Program' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
- When invoked this way the path to the python executable is not being enclosed in quotes, resulting in an error.
launch.json
configuration
The path to the Python executable is not correctly enclosed in quotes if the the "args:" parameter is added to a launch configuration.
Adding
"args": "${command:pickArgs}"
or a fixed value such as
"args": "test.txt"
to a launch configuration causes the error described.
Output for Python Debugger
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python Debugger
)
Extension version: 2025.6.0
VS Code version: Code 1.99.1 (7c6fdfb0b8f2f675eb0b47f3d95eeca78962565b, 2025-04-04T15:58:59.624Z)
OS version: Windows_NT x64 10.0.19045
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.5
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): None
Item | Value |
---|---|
CPUs | Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 x 3600) |
GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
Load (avg) | undefined |
Memory (System) | 31.83GB (17.75GB free) |
Process Argv | --crash-reporter-id c7d0ca15-d61d-42ff-9b07-a5f6c4a9ee11 |
Screen Reader | no |
VM | 0% |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
pythonrstrctxt:31112756
nativeloc1:31192215
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31280368
pythoneinst12cf:31262606
bgtreat:31268568
4gafe986:31271826
31787653:31262186
3e8i5726:31271747
49da9784:31280259
useunpkgapi:31280918
763bd867:31279164
747dc170:31275177
g20af354:31278749
7h9a3989:31280522
Activity
eleanorjboyd commentedon May 27, 2025
hm yes we were making edits in this area to handle multiple args in the input box, and so if we din't want to put quotes around it but need to review this executable issue