【发布时间】:2021-05-08 04:14:28
【问题描述】:
我正在尝试调试一个简单的 Python 程序,该程序读取 CSV 并在 VS Code 中写入一个新程序。当我设置断点时,它会被跳过。我可以使用breakpoint() 并获得基本的 Python 调试器,但我更希望能够使用 VS Code 调试器。我找到了这个SO post 和this documentation,但都没有解决这个问题。我在 Windows 上,Python 版本 3.9.1。我不是经验丰富的 Python 开发人员,因此很可能我遗漏了一些明显的东西,但我已经完成了 .NET 开发的公平份额。
更新 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}",
"console": "integratedTerminal",
"stopOnEntry": true,
"justMyCode": false
}
]
}
对于代码,我在各处设置了断点以使其正常工作,但这是我的main.py。我已经在h.get_approvers() 行上尝试了一个断点:
import adp
import hierarchy
import expensify
import sys
h = hierarchy.Hierarchy()
h.get_approvers()
更新 2:调试时的终端输出
Loading personal and system profiles took 664ms.
PS C:\Users\...\OneDrive - ZoomInfo\Dev\Sandbox\PyTest> & C:/Python39/python.exe "c:/Users/.../OneDrive - ZoomInfo/Dev/Sandbox/PyTest/main.py"
Hello world
PS C:\Users\...\OneDrive - ZoomInfo\Dev\Sandbox\PyTest>
【问题讨论】:
-
我个人在我的 MacOS 上没有遇到过 VSCode 的问题。你有没有看过官方文档code.visualstudio.com/docs/editor/debugging?
-
TERMINAL或PROBLEMS窗格中是否有任何有用的错误? -
@RazzleShazl 我按照官方文档中的 Python 特定说明设置调试器。这是我上面的第二个链接。终端或问题窗格中没有错误。
-
我没主意了。如果有帮助,这是我的
launch.jsonpastebin.com/RAtkYMFJ -
请发布您的launch.json,您的代码示例/部分,以及您在哪一行放置了断点。没有这些东西,这只是猜测。