在VS代码中调试Python无法正常工作

时间:2018-05-05 04:07:50

标签: python-3.x visual-studio-code vscode-debugger

我试图在VS Code中调试我的python脚本,但调试器甚至没有启动。单击绿色播放按钮后,蓝色栏会继续加载,而下面的栏应该变为橙色,不会发生变化,并且是蓝色。

我尝试了什么? 1.在launch.json文件中添加路径。 这是我的launch.json文件。

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${file}"
    },
    {
        "name": "Python: Attach",
        "type": "python",
        "request": "attach",
        "localRoot": "${workspaceFolder}",
        "remoteRoot": "${workspaceFolder}",
        "port": 3000,
        "secret": "my_secret",
        "host": "localhost"
    },
    {
        "name": "Python: Terminal (integrated)",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal",
        "pythonPath": "${config:python.pythonPath}"
    },
    {
        "name": "Python: Terminal (external)",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "externalTerminal",
        "pythonPath": "${config:python.pythonPath}"
    },

我在Windows高级设置和VS代码工作区设置中也正确配置了路径。

{
"python.pythonPath": "C:/Users/Admin/AppData/Local/Programs/Python/Python36-32/python.exe",
"code-runner.runInTerminal": true
}

如果我尝试在 Python:当前文件 Python:终端(集成)中运行调试,我收到以下错误消息:

C:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser>cd c:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && C:/Users/Admin/AppData/Local/Programs/Python/Python36-32/python.exe C:\Users\Admin\.vscode\extensions\ms-python.python-2018.4.0\pythonFiles\PythonTools\visualstudio_py_launcher.py c:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser 49947 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput c:\Users\Admin\Documents\PycharmProjects\Python_small_test\CSV_parser\test.py "

'cmd' is not recognized as an internal or external command,operable program or batch file.

当我尝试在 Python:终端(外部)中运行它时,IDE处于IDLE状态。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我明白了。

我只需在高级系统设置下的环境变量的路径变量中添加路径“C:\ Windows \ System32”。