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

相关推荐
SuperEugene20 小时前
Python 异步 async/await:为什么 AI 框架大量使用?| 基础篇
开发语言·人工智能·python
SMF191920 小时前
【uv】Python包管理器uv安装和应用
开发语言·python·uv
gergul20 小时前
在llama-cpp-python中使用自己编译的llama.cpp,解决pip install llama-cpp-python报错
python·llama·llama.cpp·llamacpppython
深蓝轨迹20 小时前
#Python零基础机器学习入门教程
人工智能·python·机器学习
蓝色的杯子20 小时前
Python面试30分钟突击掌握-LeetCode1-Array
开发语言·python·面试
怪祝浙20 小时前
超简洁YOLO8n快速上手人员检测
python
财经资讯数据_灵砚智能20 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(日间)2026年4月10日
人工智能·python·信息可视化·自然语言处理·ai编程
啦啦啦_999920 小时前
0. Python进阶概要
python
weixin_4080996721 小时前
OCR 识别率提升实战:模糊 / 倾斜 / 反光图片全套优化方案(附 Python / Java / PHP 代码)
图像处理·人工智能·后端·python·ocr·api·抠图
翻斗包菜21 小时前
Python 网络编程从入门到精通:TCP/UDP/Socket 实战详解
网络·python·tcp/ip