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

相关推荐
怪力左手10 分钟前
vscode扩展离线下载
ide·vscode·编辑器
toolhow11 分钟前
SelfAttenion自注意力机制
pytorch·python·深度学习
智航GIS11 分钟前
6.2 while循环
java·前端·python
qq_3363139314 分钟前
java基础-IO流(转换流)
java·开发语言·python
Stestack22 分钟前
ssh批量机器免密操作
linux·python·ssh
a程序小傲25 分钟前
得物Java面试被问:反射机制的原理和应用场景
java·python·面试
于越海25 分钟前
学习小项目:用 Python 自动统计编程课绩点(5.0 制|百分制直算|重修取最高)
开发语言·笔记·python·学习·学习方法
xingzhemengyou130 分钟前
Python GUI中常用的after
开发语言·python
郝学胜-神的一滴42 分钟前
Python抽象基类与abc模块详解:优雅设计接口的利器
开发语言·python·程序人生
小南知更鸟1 小时前
前端静态项目快速启动:python -m http.server 4173 与 npx serve . 全解析
前端·python·http