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

相关推荐
leisoo809711 分钟前
ig50数据落盘ClickHousevsTimescaleDBvsDuckDB实测对比 IG50免费开源股票数据API接口
开发语言·jvm·数据库·python·json
卷无止境14 分钟前
FastAPI 的 Metadata 到底是什么,又牵动了哪些核心概念
后端·python
卷无止境16 分钟前
FastAPI 调试实战,从断点到生产环境的排错心法
后端·python
yaoxin5211231 小时前
503. Java 反射 - 编写 ServiceFactory 类
java·开发语言·python
kyrie_sakura2 小时前
python学习笔记3 -- 流程控制语句结构
笔记·python·学习
程序员小八7772 小时前
Java 快速转 Go
java·python·golang
梦想的旅途23 小时前
Python实现企业微信文本消息发送
开发语言·python·企业微信
%473 小时前
DAY41
pytorch·python
敲代码还房贷4 小时前
VMware17 + Ubuntu22.04 共享 完整步骤
linux·python·ubuntu
测试19984 小时前
Selenium 无法定位元素的几种解决方案
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例