VS代码中的外部终端调试器

问题描述 投票:0回答:1

由于我无法在调试控制台中输入,我正在尝试在VS Code中的外部终端中运行调试器。

这是外部终端的launch.json配置文件的一部分。

{
            "name": "Python: Terminal (external)",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "cwd": "",
            "console": "externalTerminal",
            "env": {},
            "externalConsole": true,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit"
            ]
},

我添加了"externalConsole": true部分,因为他们说here和我尝试有或没有该声明。

我收到这个错误,

Debug adapter process has terminated unexpectedly

我在json文件中尝试了docs和IntelliSense,但我无法理解并让它工作。

python json debugging visual-studio-code
1个回答
1
投票

我正在使用Windows,但是,这应该可以解决您的问题。

"name": "Python: Terminal (external)",
        "type": "python",
        "request": "launch",
        "stopOnEntry": true,
        "pythonPath": "C:/Users/Zac/Anaconda3/python.exe",
        "program": "${file}",
        "cwd": "",
        "console": "externalTerminal",
        "env": {},
        "envFile": "${workspaceFolder}/.env",
        "debugOptions": [
            "RedirectOutput"
        ]
    },

您需要在“pythonPath”行中正确添加python.exe位置的路径。

另外,从“debugOptions”中取出“WaitOnAbnormalExit”和“WaitOnNormalExit”,然后使用“RedirectOutput”。从代码中删除“externalConsole”:true。

其他一切都应该保持不变。

希望有所帮助。干杯。

© www.soinside.com 2019 - 2024. All rights reserved.