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

相关推荐
我是小疯子662 分钟前
Python3.11.4离线安装PyInstaller全攻略
python
alphaTao6 分钟前
LeetCode 每日一题 2026/1/12-2026/1/18
python·算法·leetcode
Fasda1234517 分钟前
基于yolo11-C3k2-AKConv的太阳能电池片缺陷检测技术分享
python
观测云26 分钟前
AWS Lambda Python 应用可观测最佳实践(DDTrace)
python·云计算·aws
jerwey1 小时前
VSCode + Copilot下:配置并使用 DeepSeek
ide·vscode·copilot
翔云1234561 小时前
(MySQLdb._exceptions.OperationalError) (2006, ‘MySQL server has gone away‘)
网络·python
我是一只小青蛙8881 小时前
Python办公自动化:6大实用库速览
python
Duang007_1 小时前
【LeetCodeHot100 超详细Agent启发版本】两数之和 (Two Sum)
java·人工智能·python
企业对冲系统官2 小时前
基差风险管理系统集成说明与接口规范
大数据·运维·python·算法·区块链·github
花酒锄作田2 小时前
[python]Flask - Tracking ID的设计
python·flask·pytest