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

相关推荐
小酒星小杜7 小时前
如何简单地创建你的第一部漫画?从一个“可见变化”开始
人工智能·python·产品
sel_97 小时前
【OPD论文导读(二)】OPD(On-Policy Distillation)全景调研:十篇论文讲透“在自己生成的内容上学习“这件事
人工智能·python·深度学习·学习·算法·语言模型
北山小恐龙7 小时前
使用手势在电脑刷抖音
人工智能·python·深度学习·yolo·机器学习·计算机视觉
GlueNa2SiO38 小时前
01-Flask入门与环境搭建
笔记·python·学习·flask
李可以量化8 小时前
redis-py 从了解到精通(三):Redis Key 核心操作函数详解(上)
python
卷无止境8 小时前
FastAPI 实现 SSO,从协议原理到生产级落地
后端·python·fastapi
卷无止境8 小时前
FastAPI 与 RustFS 集成指南
后端·python·fastapi
青 春 记 忆8 小时前
零基础入门python25:新增账目——Decimal、日期和输入校验
python·后端开发
北风toto8 小时前
阿里云 MaxCompute通过python脚本调用odps流程和执行sql
python·阿里云·odps
ShineWinsu8 小时前
对于TRAE中配置Qt的解析
开发语言·c++·ide·vscode·qt·ai·trae