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

相关推荐
呆萌很1 分钟前
PyCharm 中使用 Anaconda
python
TonyLee0175 分钟前
vscode运行Julia项目(linux远程服务器)
vscode·julia
superman超哥11 分钟前
仓颉代码内联策略深度解析
c语言·开发语言·c++·python·仓颉
写代码的【黑咖啡】15 分钟前
Python中的文件操作详解
java·前端·python
q_302381955616 分钟前
秒级筛查+94.7%精准!华为Atlas 200 DK边缘设备解锁糖尿病视网膜病变检测新范式
人工智能·python·深度学习·智能体
AndrewHZ24 分钟前
【python与生活】从手机定位到车辆导航:GPS定位算法原理与Python实现
python·智能手机·生活·gps·定位算法·北斗卫星·车辆导航
Edward.W41 分钟前
PyQt6 打造苹果风格 ADB 图形化工具:adbUI 深度测评与实战指南
python·adb·pyqt
纪伊路上盛名在1 小时前
vscode的colab扩展目前的一些问题
ide·vscode·python·编辑器·colab·前后端
Java后端的Ai之路1 小时前
【AI编程工具】-Trae IDE+AutoDL 运行本地项目完整实操
ide·ssh·ai编程·autodl·trae
宁大小白1 小时前
pythonstudy Day41
python·机器学习