【问题标题】:How to fix this 'cmd' not recognized error to carry out the debugging in VSCode?如何修复此“cmd”无法识别的错误以在 VSCode 中进行调试?
【发布时间】:2019-11-13 23:57:49
【问题描述】:

调试时cmd is not recognized 显示并且程序没有被调试。

可能是什么问题?

我已经检查了 pathpythonpath 变量,这些似乎都很好

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.

【问题讨论】:

    标签: python visual-studio-code vscode-debugger


    【解决方案1】:

    TL;DR:cmd 不在您的 Windows 环境路径中。 %SystemRoot%\system32 添加到您的系统变量 并重新启动VSCode。


    Visual Studio Code 实际上已经为选择终端带来了原生支持,因此不再需要在路径中包含 cmd。

    • CTRL + SHIFT + P -> Terminal: Select default shell -> 选择您的终端。

    它会将这一行添加到您的 settings.json 中:

    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe" 应该已经出现了。

    或者如果你选择了 Powershell,它看起来像这样:

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

    要查看您的 settings.json 文件,只需:

    • Ctrl + , 向下滚动到 Files: Associations 并点击 Edit in settings.json

    【讨论】:

      【解决方案2】:

      这意味着cmd 不在您的路径中。要么:

      • 在控制面板中添加系统或用户变量的路径

      • 改用cmd 的完整路径(通常是C:\Windows\System32\cmd.exe),意思类似于:

      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 "

      【讨论】:

        【解决方案3】:

        如果 cmd 在您的 Windows 环境路径中,这意味着您的默认集成 shell 可能设置为 wsl bash。 更改并设置 “terminal.integrated.shell.windows”:“C:\Windows\System32\cmd.exe” 在你的设置 json 中

        你可能需要重启 VSCode 才能生效。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-12-18
          • 2020-04-16
          • 1970-01-01
          • 2018-07-25
          • 2022-08-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多