在 vscode 中调试 python 文件时,启动程序似乎 运行 在第一个断点暂停之前的完整文件

when debuging python file in vscode, launch program seems to run the full file before pause in the first breakpoint

打印行在第一个断点后面,但结果已经在终端

我试图查看 https://code.visualstudio.com/docs/python/debugging 但没有找到任何类似的参数。

编辑:

我意识到只有当我将文件命名为 django.py 时才会出现问题。

当我将文件重命名为 website.py 等其他名称时,它不会发生。

我想知道是否还有其他名称会触发此错误。

下面是我的launch.json

{
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
        }
    ]
}

这是因为django.py与其他文件冲突。

摘自 documentation

You’ll need to avoid naming projects after built-in Python or Django components. In particular, this means you should avoid using names like django (which will conflict with Django itself) or test (which conflicts with a built-in Python package).


即一些其他进程正在寻找,并且 运行 django.py。而你的文件是 over-writing 另一个文件。

要解决您的问题,请避免将文件命名为 django.pytest.py