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

相关推荐
开源量化GO11 分钟前
最新AI量化学习路径,从交易想法走到条件和动作
人工智能·python
香蕉鼠片16 分钟前
图像处理经典脚本
图像处理·python·opencv
用户2986985301429 分钟前
Python 一键导出 Excel 中的图表和形状为图片
后端·python·excel
汤米粥33 分钟前
Python爬虫——json解析
爬虫·python·json
武陵悭臾1 小时前
Python应用开发学习:如何让随机数按一定比列出现
python·学习·random·概率·随机数
蓝冰凌1 小时前
vscode 用户级 settings.json
ide·vscode·json
amongdata1 小时前
MyVoiceTyping:面向中文语音输入的本地优先开源方案
python·开源·音视频·语音识别
薛定猫AI1 小时前
【技术干货】大模型检查点可靠性评测:基于 Python 构建幻觉与指令遵循测试
开发语言·python
Mr__Miss2 小时前
Java 随机数生成器选型指南:Random、ThreadLocalRandom 与 SecureRandom
java·开发语言·python
CTA量化套保2 小时前
2026年下半年Python量化入门,先看API如何接进小流程
人工智能·python