You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spaces in python interpreter path or program result in incorrectly quoted debugging commands with arguments #233
VS Code version: 1.86.2 Extension version: v2024.0.0 OS and version: Windows 10 Pro Up-to-date Python version: 3.12 Shell: Powershell 7.4.1 Type of virtual environment used: venv with space in path.
Expected behaviour
The Python debugger should correctly quote paths that contain spaces in the Python interpreter path and the program to be debugged, ensuring commands are properly executed when arguments are taken through a launch.json configuration.
Actual behaviour
When there are spaces in the Python interpreter path or the program name, the debugger command fails due to improper quoting, leading to errors in execution.
For instance, if one's path for the interpreter were c:\Users\one\Documents\Python Folder\.venv\Scripts\python.exe, the error message they would receive would be
c:\Users\one\Documents\Python : The term 'c:\Users\one\Documents\Python' 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.
Additional detail
Currently one can side step the program issue by using escaped quotes but I have not found a method to have the venv executables path be quoted correctly.
Steps to reproduce:
Create a Python file in a directory that has a space in its name.
Set up a virtual environment in a directory with a space in its name.
Configure launch.json to use the standard "Python Debugger: Current File with Arguments" like:
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": "${command:pickArgs}"
}
Start Debugging
Note: This also happens with manually hardcoded arguments.
Same issue here. My user folder (Windows 10) happens to contain spaces, which causes problems. It seems that the debugpy configuration with arguments is behaving differently than the "current file with no arguments" one. When running with default configuration in launch.json:
The python executable and debugy launcher paths are wrapped in quotes, so it works. The following command is executed in PowerShell when running this configuration, and works: (note "User Name" with spaces)
Using launch.json, the problem only occurs in certain conditions (VSCode Version: 1.85.1 (Windows)):
A. set args to a string args: "some_arg", I get the error, since it runs:
c:; cd 'c:\Users\redacted\git\blnk'; c:\Program Files\Python311\python.exe c:\Users\redacted\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 51463 -- some_script.py c:\Users\redacted\Desktop\some_file.txt
B. set args to a list of strings args: ["some_arg"], error goes away since it runs (notice now it adds the single quotes around the python executable path in this case, unlike A above):
The terminal says it is running c:\Program Files\Python311\python.exe (with or without quotes depending on args setting for some reason, as described above)
python.pythonPath is python (no matter what I put there for folder or workspace, such as a full path, it is ignored)
PS R:\winscripts> r:; cd 'r:\winscripts'; c:\Program Files\Python311\python.exe c:\Users\user\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 42321 -- R:\winscripts\update-mod-date.py z:\files
c:\Program : The term 'c:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:26
+ r:; cd 'r:\winscripts'; c:\Program Files\Python311\python.exe c:\Use ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (c:\Program:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
this is an issue on OSX too. the following is a work around i used in my launch.json
i hard coded the value for "program" with a file path and I added single quotes around the full path name.
I hope the fix will be present soon. I just love to use VS Code!
Same issue on Windows 11. It was all running fine on some older version, hadn't written any python for a while, and I accepted the offer to upgrade everything when I fired up VSCode. Then suddenly I can't debug python anymore. Unfortunately I don't know which the old versions were. My setup is now:
Windows 11 Version 23H2 (OS Build 22631.3447)
Windows Powershell Version: 5.1.22621.2506
VSCode Version: 1.88.1
Python Extension version: v2024.4.1
Python Debugger Extension version: v2024.4.0
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": "${command:pickArgs}"
}
]
}
PS C:\Users\users\repos\usi-protocol> c:\Program Files\Python310\python.exe c:\Users\user.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 56240 -- C:\Users\user\repos\repo\code.py -a arg
c:\Program : The term 'c:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:2
I don't know if it's the same cause, but this issue seems to be reported here (microsoft answers) and it is attributed to the Python extension rather than the debugger..? However the suggest workaround (roll back to an ancient version) no longer seems to work (it fails to install for me).
Since you have multiple arguments, list syntax (brackets around multiple comma-separated values) is what you should use (and served as a workaround in my case even when there is one argument). Thanks for the tip about the single quotes but see if this more typical syntax also works:
Jacob Gustafson (@Poikilos) The issue is not with args. Args is known by people, I hope. The issue with the path to python. I do not know how/where adjust that besides renaming folders. In my case a user name was created with space and it starts from there.
Jacob Gustafson (@Poikilos) The issue is not with args. Args is known by people, I hope. The issue with the path to python. I do not know how/where adjust that besides renaming folders. In my case a user name was created with space and it starts from there.
Yes, I'm aware it is with the Python path, but in my case, changing the args syntax actually affected whether it could find Python. There is some type of cross-talk (command-splitting behavior changes for the whole command when the args is a string vs a list). My earlier comment gives an example, and may help the devs diagnose the issue.
Jacob Gustafson (@Poikilos) The issue is not with args. Args is known by people, I hope. The issue with the path to python. I do not know how/where adjust that besides renaming folders. In my case a user name was created with space and it starts from there.
Yes, I'm aware it is with the Python path, but in my case, changing the args syntax actually affected whether it could find Python. There is some type of cross-talk (command-splitting behavior changes for the whole command when the args is a string vs a list). My earlier comment gives an example, and may help the devs diagnose the issue.
The setting, "${command:pickArgs}". Can it parse multiple args?
I have tried many ways to input multiple args. But it always be one arg parsed into my program.
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.
Reacted by Rob McGee, Jacob Scherber, Jesus Eguiluz, rbown-vsco, Cosmo Zhang and WayneSchou
Can confirm, issue is still present. Spaces in the interpreter path (in this case, an interpreter in a venv) causes "path/until/space" to be executed.
I've enabled the setting to use the environment manager as well.
What about if debugpy is installed in some user directory that has spaces ?
Like:
C:\Users<redacted user with spaces>.vscode\extensions\ms-python.debugpy-2025.16.0-win32-x64\bundled\libs\debugpy\launcher
Activity
metamoof commentedon Apr 5, 2024
Same thing is happening to me, both with type python and debugpy
joeri-s commentedon Apr 10, 2024
Same issue here. My user folder (Windows 10) happens to contain spaces, which causes problems. It seems that the debugpy configuration with arguments is behaving differently than the "current file with no arguments" one. When running with default configuration in
launch.json:{ "name": "Python Debugger: Current File", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal" }The python executable and debugy launcher paths are wrapped in quotes, so it works. The following command is executed in PowerShell when running this configuration, and works: (note "User Name" with spaces)
However, the configuration with arguments results in the following command being called, which is results in the same problem as the original ticket:
Wrapping the
python.exeanddebugpy/launcherpaths in quotes here would solve the issue for users with spaces in their user folder path name.Poikilos commentedon Apr 12, 2024
Using launch.json, the problem only occurs in certain conditions (VSCode Version: 1.85.1 (Windows)):
A. set args to a string
args: "some_arg", I get the error, since it runs:c:; cd 'c:\Users\redacted\git\blnk'; c:\Program Files\Python311\python.exe c:\Users\redacted\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 51463 -- some_script.py c:\Users\redacted\Desktop\some_file.txtB. set args to a list of strings
args: ["some_arg"], error goes away since it runs (notice now it adds the single quotes around the python executable path in this case, unlike A above):c:; cd 'c:\Users\redacted\git\blnk'; & 'c:\Program Files\Python311\python.exe' 'c:\Users\redacted\.vscode\extensions\ms-python.debugpy-2024.0.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '51492' '--' 'some_script.py' 'c:\Users\redacted\Desktop\some_file.txt'The terminal says it is running
c:\Program Files\Python311\python.exe(with or without quotes depending on args setting for some reason, as described above)python.pythonPathispython(no matter what I put there for folder or workspace, such as a full path, it is ignored){ "version": "0.2.0", "configurations": [ { "name": "some_script some_file.txt", "type": "debugpy", "request": "launch", "program": "some_script.py", "console": "integratedTerminal", "args": ["c:\\Users\\redacted\\Desktop\\some_file.txt"] } ] }boomshankerx commentedon Apr 13, 2024
Confirmed.
Version: 1.88.0 (system setup)
Commit: 5c3e652f63e798a5ac2f31ffd0d863669328dc4c
Date: 2024-04-03T13:26:18.741Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.19045
{ "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Current File with Arguments", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal", "args": "${command:pickArgs}" } ] }peta909 commentedon Apr 20, 2024
this is an issue on OSX too. the following is a work around i used in my launch.json
i hard coded the value for "program" with a file path and I added single quotes around the full path name.
I hope the fix will be present soon. I just love to use VS Code!
`{
"version": "0.2.0",
"configurations": [
}`
my setup
Version: 1.88.1 (Universal)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:42:52.765Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin x64 23.4.0
da151575 commentedon Apr 22, 2024
Same issue on Windows 11. It was all running fine on some older version, hadn't written any python for a while, and I accepted the offer to upgrade everything when I fired up VSCode. Then suddenly I can't debug python anymore. Unfortunately I don't know which the old versions were. My setup is now:
Windows 11 Version 23H2 (OS Build 22631.3447)
Windows Powershell Version: 5.1.22621.2506
VSCode Version: 1.88.1
Python Extension version: v2024.4.1
Python Debugger Extension version: v2024.4.0
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": "${command:pickArgs}"
}
]
}
PS C:\Users\users\repos\usi-protocol> c:\Program Files\Python310\python.exe c:\Users\user.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher 56240 -- C:\Users\user\repos\repo\code.py -a arg
c:\Program : The term 'c:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:2
I don't know if it's the same cause, but this issue seems to be reported here (microsoft answers) and it is attributed to the Python extension rather than the debugger..? However the suggest workaround (roll back to an ancient version) no longer seems to work (it fails to install for me).
Poikilos commentedon Apr 23, 2024
Since you have multiple arguments, list syntax (brackets around multiple comma-separated values) is what you should use (and served as a workaround in my case even when there is one argument). Thanks for the tip about the single quotes but see if this more typical syntax also works:
SergeyZa commentedon Apr 23, 2024
Jacob Gustafson (@Poikilos) The issue is not with args. Args is known by people, I hope. The issue with the path to python. I do not know how/where adjust that besides renaming folders. In my case a user name was created with space and it starts from there.
Poikilos commentedon Apr 23, 2024
Yes, I'm aware it is with the Python path, but in my case, changing the args syntax actually affected whether it could find Python. There is some type of cross-talk (command-splitting behavior changes for the whole command when the args is a string vs a list). My earlier comment gives an example, and may help the devs diagnose the issue.
SergeyZa commentedon Apr 23, 2024
Interesting... will try.
19 remaining items
shinpei710 commentedon Sep 11, 2024
The setting, "${command:pickArgs}". Can it parse multiple args?
I have tried many ways to input multiple args. But it always be one arg parsed into my program.
eleanorjboyd commentedon Dec 2, 2024
@xlbljz - since this is a long thread could you create a new issue in regards to this problem or ask in the discussions sections of this repo. Thanks!
boomshankerx commentedon Jul 19, 2025
This issue should not be closed. It still exists.
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.SiDtheTurtle commentedon Sep 9, 2025
Issue still exists. Workaround is, as per the above, add square brackets around the args in launch.json.
doumeki commentedon Sep 10, 2025
funny microsoft,the bug havent fix.
KobeRiddle-dev commentedon Oct 4, 2025
Can confirm, issue is still present. Spaces in the interpreter path (in this case, an interpreter in a venv) causes "path/until/space" to be executed.
I've enabled the setting to use the environment manager as well.
ssgen commentedon Nov 28, 2025
What about if debugpy is installed in some user directory that has spaces ?
Like:
C:\Users<redacted user with spaces>.vscode\extensions\ms-python.debugpy-2025.16.0-win32-x64\bundled\libs\debugpy\launcher
Launching without:
"args": "${command:pickArgs}"correctly quotes python executable path and launcher path:
& 'c:\<redacted path>\.venv\Scripts\python.exe' 'c:\Users\<redacted user>\.vscode\extensions\ms-python.debugpy-2025.16.0-win32-x64\bundled\libs\debugpy\launcher' '55936' '--' 'C:\<redacted script path>.py'Enabling the above destroys the quoting:
c:\<redacted path>\.venv\Scripts\python.exe c:\Users\<redacted user>\.vscode\extensions\ms-python.debugpy-2025.16.0-win32-x64\bundled\libs\debugpy\launcher 57334 -- C:\<redacted script path>.py arg1 arg2 arg3Thanks for looking again into it.
Better yet - where can I modify the quoting behaviour ?