python - 如何修复此 'cmd' 无法识别错误以在 VSCode 中进行调试?

标签 python visual-studio-code vscode-debugger

调试时显示cmd is not recognize并且程序未调试。

可能是什么问题?

我已经检查了 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.

最佳答案

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 实际上带来了对选择终端的 native 支持,因此不再需要将 cmd 包含到您的路径中。

  • CTRL + SHIFT + P -> 终端:选择默认 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 + , 向下滚动到文件:关联,然后点击在 settings.json 中编辑

关于python - 如何修复此 'cmd' 无法识别错误以在 VSCode 中进行调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56867659/

相关文章:

linux - 如何在 VSCODE 上使用 root 权限调试您的应用程序?

visual-studio-code - 使用 Visual Studio Code 打印完整的数组项

angular - TSLint 和 VSCode 未在 .ts 文件中显示红线

python - python socket.recv() 方法如何知道已经到达消息结尾?

python - 需要一种方法来确定文件是否已写入

javascript - 将命令附加到已有的键绑定(bind)

python - 在 VS Code 中使用路径作为参数值设置自定义启动器(Flask - 证书路径)

go - 在vscode中调试go不会在断点处停止,调试器启动时说 "Could not find file ..."

python - Tensorflow:如何在调用 tf.reduce_sum 时忽略数组的一部分

python - 检查列表是否在python中递增1