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

相关推荐
RSTJ_162522 分钟前
PYTHON+AI LLM DAY ONE HUNDRED AND EIGHTEEN
python
tkevinjd1 小时前
MiniCode 项目详解7:Memory 记忆系统
大数据·python·搜索引擎·llm·agent
郭老二2 小时前
【Python】Web框架 FastAPI 详解
python·fastapi
DFT计算杂谈2 小时前
交错磁研究进展材料物性与交叉应用
数据库·人工智能·python·opencv·算法
敖行客 Allthinker2 小时前
docker容器安装Python反推镜像步骤(适用于临时调试用)
python·docker·容器
rrrjqy2 小时前
夏普比率与 Beta——Quant-for-Beginners 量化入门Task7
python·金融
min(a,b)4 小时前
学习第 6 天:类型注解、装饰器与高级特性
python·学习
兮动人4 小时前
Python字符串类型
开发语言·python·python字符串类型
码云骑士4 小时前
80-指令微调Instruction-Tuning-指令数据构造-多任务训练-过拟合检测
python
爱昏羔5 小时前
上篇:从PDF到向量库 — 物流行业RAG系统的知识库构建全解析
python·langchain·pdf·agent·rag