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

相关推荐
Python图像识别-12 分钟前
基于yolov8的钢铁缺陷检测系统-2027毕业版(UI界面+Python项目源码+模型+标注好的数据集)
开发语言·python·yolo
aqi0012 分钟前
15天学会AI应用开发(十五)使用LangChain封装AI执行链
人工智能·python·大模型·ai编程·ai应用
kisbad40 分钟前
Day 012|Embedding 和向量数据库:知识库检索到底在检什么
数据库·python·embedding·agent
va学弟1 小时前
LeetCode 热题 100 题解(1):哈希
python·算法·leetcode·哈希算法
言乐61 小时前
Python实现基本搜索引擎
java·linux·开发语言·python·搜索引擎
FriendshipT1 小时前
Ultralytics:解读C3k2模块
人工智能·pytorch·python·深度学习·目标检测
啦啦啦_99991 小时前
Agent项目
python
乱写代码1 小时前
LangChain学习--Document
python
风之所往_2 小时前
Python 3.11 新特性全面总结
python·python3.11