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

相关推荐
曲幽5 小时前
FastAPI 身份验证总踩坑?这份 FastAPI Users “避坑指南”请收好
python·fastapi·web·jwt·oauth2·user·authentication
装不满的克莱因瓶6 小时前
掌握 RNN 与 LSTM 模型结构
人工智能·python·rnn·深度学习·神经网络·ai·lstm
何以解忧,唯有..6 小时前
Python包管理工具pip:从入门到精通
开发语言·python·pip
金銀銅鐵6 小时前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf6 小时前
Python 模块与包的导入导出
前端·后端·python
ice8130331817 小时前
【Python】Matplotlib折线图绘制
开发语言·python·matplotlib
copyer_xyf7 小时前
Python venv 虚拟环境
前端·后端·python
林爷万福8 小时前
GitHub 开源光谱数据处理项目推荐
python·光纤光谱仪
copyer_xyf8 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python
Full Stack Developme8 小时前
Spring Bean 依赖注入
python·spring·log4j