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

相关推荐
Lyra_Infra几秒前
云效主机部署场景下 Python 服务生命周期问题复盘
后端·python
LaughingZhu11 分钟前
Product Hunt 每日热榜 | 2026-09-08
java·ide·深度学习·百度·intellij-idea
刀鋒偏冷26 分钟前
CentOS 7 配置 Python 3.12.4 + RTX 4090 深度学习环境全记录
python·深度学习·centos
DreamLife☼36 分钟前
Agent开发环境搭建完全指南
python·docker·typescript·node·工业知识点
李可以量化41 分钟前
miniqmt 行情的备选方案 ---tdxrs(下)
python
2601_962381581 小时前
Python爬虫requests框架详解!零基础学会网络请求,抓取全网数据
爬虫·python·网络请求·数据抓取·requests框架
李可以量化1 小时前
miniqmt 行情的备选方案 ---tdxrs(上)
python
Cenxi2 小时前
f-string 完全手册:60 题从入门到实战
python
2601_962299882 小时前
Python编写Linux命令指南
linux·python·开发·命令·指南
此冬歌咏2 小时前
自动化服务器运维监控系统(python+shell)
linux·运维·服务器·开发语言·python·自动化