knowledge-vault/sources/references/开发笔记/VSCode.md

40 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 在 VS Code 中配置调试器
你可以按照以下步骤在 VS Code 中配置调试器,以附加到运行中的 Streamlit 服务:
1. 打开 VS Code 并进入调试视图(左侧栏中的虫子图标)。
2. 点击顶部的齿轮图标,打开 `launch.json` 文件。
3.`launch.json` 文件中添加一个新的调试配置,内容如下:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Streamlit",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
]
}
]
}
```
这个配置会告诉 VS Code 调试器附加到本地的 5678 端口,并将本地工作区目录映射到远程目录。
4. 启动你的应用程序(运行 run.py 文件)。
5. 在 VS Code 中选择刚刚添加的调试配置 "Attach to Streamlit"。
6. 点击绿色的播放按钮开始调试。
这样VS Code 调试器就会附加到运行中的 Streamlit 服务,你可以在 app.py 文件中设置断点,并进行调试。
找到具有 1 个许可证类型的类似代码