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

相关推荐
Csvn19 小时前
🌟 LangChain 30 天保姆级教程 · Day 13|OutputParser 进阶!让 AI 输出自动转为结构化对象,并支持自动重试!
python·langchain
cch891820 小时前
Python主流框架全解析
开发语言·python
sg_knight20 小时前
设计模式实战:状态模式(State)
python·ui·设计模式·状态模式·state
好运的阿财20 小时前
process 工具与子agent管理机制详解
网络·人工智能·python·程序人生·ai编程
张張40820 小时前
(域格)环境搭建和编译
c语言·开发语言·python·ai
weixin_4235339921 小时前
【Windows11离线安装anaconda、python、vscode】
开发语言·vscode·python
爱分享的阿Q21 小时前
STM32现代化AI开发环境搭建:从Keil到VSCode+AI的范式转移
人工智能·vscode·stm32
Ricky111zzz21 小时前
leetcode学python记录1
python·算法·leetcode·职场和发展
Freak嵌入式21 小时前
LVGL基础知识和概念:视觉样式与资源系统
ide·驱动开发·嵌入式·lvgl·micropython·upypi
小白学大数据21 小时前
Selenium+Python 爬虫:动态加载头条问答爬取
爬虫·python·selenium