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

相关推荐
先做个垃圾出来………11 小时前
Python 中 kwargs.get() 方法详解
开发语言·python
热爱生活的五柒11 小时前
配置vscode的ssh离线部署,但是Stable-cmmit-id一直会后面添加个staging这个后缀将文件名修改
ide·vscode·ssh
大闲在人11 小时前
Trae builder 实战: 让 C++ 函数像 Python 一样返回多个值
c++·python·ai编程
柠檬丶抒情11 小时前
Rust深度学习框架Burn 0.20是否能超过python?
python·深度学习·rust·vllm
reesn12 小时前
celery 使用说明
python
duansamve12 小时前
VSCode中如何搭建JAVA+MAVEN开发环境?
java·vscode·maven
ValhallaCoder12 小时前
Day50-图论
数据结构·python·算法·图论
好好学操作系统12 小时前
notion+excel自动创建表格| 了解了notion api
数据库·python·oracle·excel·notion
一晌小贪欢12 小时前
用 PyQt5 做一个「批量目录重命名」工具,并打包成带图标的 EXE
开发语言·驱动开发·python·python基础·python小白
sunfove12 小时前
Python制作小游戏:用线性代数思想构建 2048 游戏引擎
python·线性代数·游戏引擎