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

相关推荐
Astro_ChaoXu9 分钟前
GAMSE使用日志与教程(高分辨率光谱数据缩减)
linux·数据库·python
人工智能培训13 分钟前
基于知识图谱的故障推理方法与算法
人工智能·python·深度学习·机器学习·知识图谱·故障诊断
ID_180079054731 小时前
超详细:Python 调用淘宝商品详情 API 完整教程
开发语言·python
平常心cyk1 小时前
Python基础快速复习——函数的多种传参方式
python
lanboAI1 小时前
基于卷积神经网络的舌苔诊断系统,resnet50,alexnet, shufflenet模型【pytorch框架+python源码】
pytorch·python·cnn
QWsin1 小时前
【Pydantic】Pydantic 是什么?
python
WeeJot嵌入式1 小时前
爬虫对抗:ZLibrary反爬机制实战分析
爬虫·python·网络安全·playwright·反爬机制
Bert.Cai2 小时前
Python input函数作用
开发语言·python
Fairy要carry2 小时前
项目03-手搓Agent之团队协作(发消息/分配任务)
linux·前端·python
qq_283720052 小时前
VSCode 编译 Qt 5.12 QML 完整教程(Windows + MinGW)
windows·vscode·qt