How to fix this 'cmd' not recognized error to carry out the debugging in VSCode?

Viewed 2381

While debugging cmd is not recognized is displayed and program is not debugged.

What can be the problem?

I have already checked the path and pythonpath variables and those seem to be just fine

bash
C:\Users\rahul\Desktop\vscode\.vscode>cd c:\Users\rahul\Desktop\vscode\.vscode && 

cmd /C "set "PYTHONIOENCODING=UTF-8" && 

set "PYTHONUNBUFFERED=1" && 

C:\Users\rahul\AppData\Local\Programs\Python\Python37-32\python.exe c:\Users\rahul\.vscode\extensions\ms-python.python-2019.6.22090\pythonFiles\ptvsd_launcher.py --default --client --host localhost
    --port 50265 c:\Users\rahul\Desktop\vscode\.vscode\s.py "
    'cmd' is not recognized as an internal or external command,
    operable program or batch file.
3 Answers

TL;DR: cmd is not in your Windows Environment Path. enter image description here add %SystemRoot%\system32 to your System Variables and restart VSCode.


Visual Studio Code has actually brought native support for selecting your terminal, so including cmd into your path is nolonger necessary.

  • Press CTRL + SHIFT + P -> Terminal: Select default shell -> select your terminal.

It will add this line to your settings.json:

"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe" should have appeared.

Or if you chose Powershell, it will look like this:

"terminal.integrated.shell.windows": "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"

To view your settings.json file, simply:

  • Ctrl + , scroll down to Files: Associations and click Edit in settings.json.

It means that cmd is not in your path. Either:

  • Add the path to the system or user variables in the control panel

  • Use the full path to cmd instead (typically C:\Windows\System32\cmd.exe), meaning something like:

cd c:\Users\rahul\Desktop\vscode\.vscode && C:\Windows\System32\cmd.exe /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && C:\Users\rahul\AppData\Local\Programs\Python\Python37-32\python.exe c:\Users\rahul\.vscode\extensions\ms-python.python-2019.6.22090\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 50265 c:\Users\rahul\Desktop\vscode\.vscode\s.py "

If cmd is in your Windows Environment Path, that means that, probably, your default integrated shell is set to wsl bash. Change it and set "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe" in your settings json

You may need to restart VSCode for this to take effect.

Related