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

相关推荐
weixin_BYSJ198717 分钟前
springboot校园自习室管理小程序---附源码32142
java·javascript·spring boot·python·django·flask·php
2501_9159214333 分钟前
iOS开发环境搭建详解 Xcode 配置与快蝎轻量级工具选择
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
用户8356290780511 小时前
使用 Python 在 PDF 中绘制线条、矩形和自定义图形
后端·python
wang_yb1 小时前
用方差阈值过滤掉“惰性特征”
python·ai·databook
RFID固定资产管理系统3 小时前
公司RFID管理系统揭秘
大数据·python
IVEN_3 小时前
Python官方包、Conda、uv,应该怎么选
python
凡尘——雨落凡尘4 小时前
Python列表索引越界IndexError问题深度解析与解决办法
python·indexerror·list index out of range
Metaphor6924 小时前
使用 Python 在 Word 文档中添加或删除文本框
python·word
wardenlzr4 小时前
VSCode 运行 Live Server 提示「Windows 找不到文件 Chrome」问题全解析
chrome·windows·vscode
程序员more4 小时前
我用 AI,20 分钟做了一个 VSCode 股票摸鱼插件
人工智能·vscode