一、本地配置
1.1 安装python插件
1.2 配置python环境
在右下角就可以切换python环境,太简单了!
1.3 Debug说明
打断点直接开启!
在debug的过程中,还可以输入打印中间变量或者做一些测试
二、远程连接
2.1 下载远程工具
2.2 连接远程
下载后出现,这个图标,然后连接输入密码即可:
2.3 安装python插件
远端仍然要安装python插件
2.3 设置当前路径
代码里配置路径
2.4 远程访问免密
https://blog.csdn.net/qq_45956730/article/details/137601010
2.5 设置运行脚本参数
根目录下:.vscode/launch.json
如果没有就选择debug栏点这个配置:
-
launch.json
的内容
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "debugpy",
"request": "launch",
"program": "libs/chatchat-server/chatchat/cli.py", # 运行文件
"console": "integratedTerminal",
"cwd": "/xxx/codes/langchain-chatchat-0.3.0", # 工作目录
"justMyCode": true,
"args": ["start", "-a"] # 运行参数
}
]
}
然后点运行:
2.6 设置环境变量
仍然是在前面的launch.json
中增加内容:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "debugpy",
"request": "launch",
"program": "cli.py",
"console": "integratedTerminal",
"cwd": "/xxx/codes/langchain-chatchat-0.3.0/libs/chatchat-server/chatchat",
"justMyCode": true,
"args": ["start", "-a"],
"env": {
"CHATCHAT_ROOT": "/xxx/codes/langchain-chatchat-0.3.0/libs/chatchat-server/chatchat/data"
} # 这里则是增加环境变量
}
]
}
然后仍然按照上述方式启动即可。
2.7 调试怎么看module里面的东西
"justMyCode": true, ==> false
2.8 如何格式化python代码
需要安装插件autopep8