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

相关推荐
用户8356290780512 分钟前
使用 Python 在 PowerPoint 中生成并自定义饼图与环形图
后端·python
棉猴5 分钟前
python海龟绘图之倾转
python·turtle·海龟绘图·titlangle·tilt
小白学大数据35 分钟前
基于大模型的Python智能爬虫:语义识别与数据清洗实践
开发语言·爬虫·python·数据分析
Cloud_Shy61837 分钟前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(附录 B 高级 VS Code 功能)
vscode·python·jupyter·数据分析·excel
进击切图仔42 分钟前
从零手写 RAG
python·huggingface·rag
Dxy12393102161 小时前
Python请求方式介绍:JSON、表单及其他常见数据传输格式
数据库·python·json
西洼工作室1 小时前
个人开发者接入阿里云号码认证服务AliCloud-NirvanaPns实现一键登录
python·阿里云·uni-app·全栈·认证授权
半城抹茶1 小时前
TradingAgents-CN 项目目录文档
python
光影6271 小时前
Selenium自动化测试---实战踩坑实录
python·selenium·测试工具·百度
HappyAcmen2 小时前
2.lcut返回列表用法
python