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

相关推荐
BD_Marathon42 分钟前
安装Jupyter notebook
ide·python·jupyter
Zlzxzw1 小时前
End-to-End Autonomous Generation of Human Assembly Plans
python
Wellijohn1 小时前
2000 个请求、30% 失败率:我把 Python 批量并发的限流和重试参数算了一遍
后端·python·性能优化
Logintern093 小时前
deep agents 多智能体模式——规划与委派
python·langchain
2601_967980115 小时前
Python 办公自动化合集 ⑰:Excel自动计算——总和/平均分/最大值
python·pycharm·办公自动化·数据处理·excel自动计算
databook7 小时前
时间序列预测,模型换了一圈为什么没变好
python·数据分析
reasonsummer8 小时前
【教学类-07-17】20261119大3班破译电话号码HTML实际操作(添加“跳过按钮”和“返回按钮”在底部、增加“自编题目+解题”部分)
python·html
2601_9679801111 小时前
Python闭包(Closure)详解
python·作用域·装饰器·函数式编程·闭包
AI创界者11 小时前
ComfyUI 进阶实战:MiniMax-H3 视频人物脸部替换工作流全解析(对比 Face 5.5 实测与避坑指南)
人工智能·python·aigc
承渊政道11 小时前
【Python编程快速上手—让繁琐工作自动化】(模式匹配与正则表达式:从找到一个号码到批量提取信息)
python·正则表达式·pycharm·自动化·模式匹配