如何为 VS Code 设置 python 调试器?

How to set up python debugger for VS Code?

我在 Windows 和我的公司 Mac 上使用了相同的设置,但在 Mac 上它似乎无法正常工作?

我收到错误:

The debug type is not recognized. Make sure that you have a corresponding debug extension installed and that it is enabled.

它没有将 "type": "python" 识别为调试配置。

您需要为该工作区再次安装 Python extension for VS Code on your Mac copy of VS Code. Then, follow the instructions from the VS Code docs on setting it up Python debug configurations in Visual Studio Code

The Python extension supports debugging of a number of types of Python applications.
...

Initialize configurations

A configuration drives VS Code's behavior during a debugging session. Configurations are defined in a launch.json file that's stored in a .vscode folder in your workspace.

从您的 launch.json 文件的外观来看,安装扩展后您就可以开始了。如果它仍然无法将 "type": "python", 识别为调试配置,请尝试重新加载 VS Code and/or 确保为当前工作区启用扩展: