Search code examples
pythonvisual-studio-codevscode-debugger

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


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.

Solution

  • 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.