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

相关推荐
Niuguangshuo1 小时前
DeepFilterNet 3:端侧实时全带降噪的开源标杆
python
第一程序员2 小时前
AI 辅助编程的 7 个误区:把模型当高级搜索引擎是对它的最大浪费
python·rust·github
Groundwork Explorer3 小时前
W5500 网卡编程初始化与使用指南
python·单片机
逸Y 仙X3 小时前
MCP(模型控制协议)完全指南:从核心概念到实战开发
python·大模型·llm·ai编程·mcp
WILLF4 小时前
前端视角:Python requests vs JS axios
前端·python
哒哒哒5285204 小时前
69. Python: 核心语法-面向对象基础-案例(教务系统)
python
何以解忧,唯有..4 小时前
Python 中获取目录操作完全指南
windows·python·microsoft
南京云森杉木桩4 小时前
常见打桩木品牌推荐,选对材质让工程更稳固
人工智能·python·材质
总有刁民想爱朕ha5 小时前
Python PyQt5图片批量转MP4视频工具:本地离线免费无水印,完整代码
开发语言·python·qt
zyj8890915 小时前
濮阳工厂目视化设计安全警示牌材质怎么选耐用
python·安全·材质