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

相关推荐
Li emily3 分钟前
解决了用美股历史数据api分析价格波动的困扰
数据库·人工智能·python
Xpower 178 分钟前
PHM念叨叨系列--工业场景大模型幻觉治理
人工智能·python·语言模型
请数据别和我作队9 分钟前
基于 DeepSeek API 的 ASR 文本纠错脚本实战:Python 多线程批量处理 JSONL 语音转写数据
开发语言·经验分享·python·自然语言处理·nlp
xyh4ck17 分钟前
Claude Code for VSCode:Remote SSH 环境下的免登录问题分析
ide·vscode·ssh
@BruceYan@22 分钟前
VSCode Insiders 添加 OpenAI 兼容模型
ide·vscode·编辑器·copilot·自定义模型
mengsi5540 分钟前
Antigravity IDE 在浏览器上 verify 成功但本地 IDE 没反应 “开启Tun依然无济于事” —— 解决方案
前端·ide·chrome·antigravity
Circ.41 分钟前
文本相似性对比python代码
开发语言·python·相似度
weifont1 小时前
太烧token了,我用Ai写了一个vscode的插件wps-editor(已开源)
人工智能·vscode·wps
Ahtacca1 小时前
基于决策树算法的动物分类实验:Mac环境复现指南
python·算法·决策树·机器学习·ai·分类
萌>__<新1 小时前
AI聊天助手-测试报告
人工智能·python