Vscode 配置python调试环境

前言

与c++配置调试环境类似,利用vscode配置

Debug 配置

只需要配置launch.json中即可

cpp 复制代码
{
    // 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 Debugger: Current File with Arguments",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceFolder}/xxx.py",
            "console": "integratedTerminal",
            "args": [],
            "env": {
                "CUDA_VISIBLE_DEVICES": "4",
                "DISPLAY": "xxx:xxx:0.0"
            }
        }
    ]
}
通过设置DISPLAY 可以借助Mobaxterm 进行转发
通过设置CUDA_VISIBLE_DEVICES可以

单元测试文件配置

unittest

setting.json中详细配置位置

cpp 复制代码
"python.testing.unittestArgs": [
    "-v",
    "-s",
    "./core/tests/",
    "-p",
    "test_*.py"
],

例如在本例中,将core/tests中所有的都读入

配置成功后即可找到,在此处运行即可

测试配置参考

https://blog.csdn.net/weixin_46074689/article/details/144992483

相关推荐
疯狂成瘾者6 分钟前
增强型大模型代理
python
小李云雾7 分钟前
FastAPI 后端开发:文件上传 + 表单提交
开发语言·python·lua·postman·fastapi
Legend NO248 分钟前
数据资产评估风险识别、分析与管控体系建设
大数据·人工智能·python
vonlycn10 分钟前
Android Studio 5.3.3 新项目编译报错解决
android·ide·android studio
llm大模型算法工程师weng13 分钟前
Python敏感词检测方案详解
开发语言·python·c#
Ricky111zzz16 分钟前
leetcode学python记录2
python·算法·leetcode·职场和发展
毕胜客源码19 分钟前
改进yolov8的香蕉成熟度检测系统,改进前后的模型指标对比,有技术文档,支持图像、视频和摄像实时检测
人工智能·python·深度学习·yolo·django
H Journey24 分钟前
VSCode下CMake使用
vscode·cmake
NeilNiu24 分钟前
lm-Evaluation Harness使用
python
9分钟带帽25 分钟前
vscode中配置Qt6和CMake的开发环境
c++·vscode·cmake