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

相关推荐
小艳加油10 分钟前
Python机器学习与深度学习;Transformer模型/注意力机制/目标检测/语义分割/图神经网络/强化学习/生成式模型/自监督学习/物理信息神经网络等
python·深度学习·机器学习·transformer
weixin_307779131 小时前
VS Code配置MinGW64编译GNU 科学库 (GSL)
开发语言·c++·vscode·算法
学行库小秘2 小时前
ANN神经网络回归预测模型
人工智能·python·深度学习·神经网络·算法·机器学习·回归
Yn3122 小时前
在 Python 中使用 json 模块的完整指南
开发语言·python·json
秋难降2 小时前
线段树的深度解析(最长递增子序列类解题步骤)
数据结构·python·算法
猿榜2 小时前
Python基础-控制结构
python
Ratten2 小时前
【Python 实战】---- 实现一个可选择、配置操作的批量文件上传工具(三)上传类的实现
python
阿里云大数据AI技术3 小时前
【跨国数仓迁移最佳实践6】MaxCompute SQL语法及函数功能增强,10万条SQL转写顺利迁移
python·sql
ala咪3 小时前
切换VSCODE 中的默认 shell
vscode
杜子不疼.4 小时前
《Python学习之文件操作:从入门到精通》
数据库·python·学习