英文:
How to debug python in vscode?
问题
我有点困惑。如果 VSCode 不在与此脚本相同的文件夹中,我无法启动 Python 调试。但我可以使用“运行 Python 文件”启动它。
如果我将以下文本添加到 launch.json 中:
{
"name": "Python: Debug script",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}"
}
然后我可以使用“运行和调试”按钮启动调试。如何使“调试 Python 文件”按钮工作?
英文:
Im little confused. I can not start debug python if vscode is not located on same folder with this script. But i can start it with "Run python file".
If i add to launch.json this text:
{
"name": "Python: Debug script",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}"
}
then i can start debug it with Run And Debug button. How to make it works the "Debug python file" button?
答案1
得分: 2
请注意,按钮中的Debug Python File选项不使用launch.json中的配置。如果您需要使用launch.json配置来调试脚本,您需要点击Run and Debug面板上的绿色三角形按钮,或者在Run菜单下使用Start Debugging或Run Without Debugging选项。
如果您想要调试特定脚本并配置*program*选项。
至于右上角的播放按钮是否可以配置,您可以查看几个现有的GitHub链接。
VS Code和Python:配置编辑器标签旁边的“运行”按钮
英文:
It should be noted that the Debug Python File options in the button do not use the configuration in launch.json. If you need to use the launch.json configuration to debug the script, you need to click the green triangle button on the Run and Debug panel, or use the Start Debugging
or Run Without Debugging
under the Run menu.
If you want to debug a specific script and configure the program option.
As for whether the play button in the upper right corner can be configured, there are several existing GitHub links you can view.
Allow "Run Python File in Terminal" button to be configurable
VS Code and Python: configure the "Run" button next to the editor tabs
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论