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

相关推荐
码云骑士18 分钟前
18-生成器不只是省内存(上)-yield的状态机模型与帧暂停
c语言·开发语言·python
长空任鸟飞_阿康20 分钟前
RAG 文档摄入全链路,从原理到生产落地
vue.js·人工智能·python
程序猿零零漆22 分钟前
Python核心进阶三连:闭包装饰器、深浅拷贝、网络编程从原理到实战
网络·python
Watink Cpper30 分钟前
VSCode通过ChatGPT5.5登陆codex:sign-in could not be complete 问题解决方案
ide·vscode·编辑器·codex·gpt5.5
yongche_shi31 分钟前
ragas官方文档中文版(十六)
python·ai·智能体·ragas·使用工具
三块可乐两块冰35 分钟前
rag学习5
linux·前端·python
DXM052138 分钟前
第11期| 遥感图像分类模型:ResNet_DenseNet原理+实战训练
人工智能·python·深度学习·机器学习·分类·数据挖掘·ageo
SilentSamsara42 分钟前
模型部署实战:FastAPI + ONNX + Docker 的推理服务化
人工智能·pytorch·python·深度学习·机器学习·fastapi
聆风吟º1 小时前
Python基础数据类型(一):数字类型
开发语言·python·float·int·bool·数字类型
Tisfy1 小时前
LeetCode 3838.带权单词映射:求和、取模、拼接(附python一行版)
python·算法·leetcode·字符串·题解·模拟·取模