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

相关推荐
量化吞吐机4 分钟前
近期AI量化开发,先跑最小流程再谈复杂功能
人工智能·python
杰佛史彦明110 分钟前
PDF 表格转 CSV:Python 实现方法与代码解析
开发语言·python·pdf
智写-AI19 分钟前
推荐一下好用的降英文AI工具工具
人工智能·python
zzzll111122 分钟前
Typora插件开发指南:打造专属IDE式写作环境
ide·学习·计算机·大模型·llm·知识
snow@li33 分钟前
VSCode:学习手册 / 全景梳理与深度分析
ide·vscode
江华森1 小时前
Python神经网络编程(四):Python从零搭建神经网络
开发语言·python·神经网络
nothing&nowhere11 小时前
用 Python 做问卷数据清洗:无效样本检测与处理实战
开发语言·python·数据清洗·数据处理·问卷星·问卷星脚本·刷问卷
花酒锄作田11 小时前
如何发布自己的 Python 库到 PyPI
python
researcher-Jiang11 小时前
Design Patterns——Template Method入门到情景实战
python·设计模式·模板方法模式