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

相关推荐
tryCbest1 分钟前
PyCharm有利于开发的常用设置
python·pycharm
hnxaoli13 分钟前
统信小程序(十一)快捷地址栏
linux·python·小程序
weixin_4219226914 分钟前
机器学习模型部署:将模型转化为Web API
jvm·数据库·python
twc82915 分钟前
Query 改写 大模型测试的数据倍增器
开发语言·人工智能·python·rag·大模型测试
Fortune7916 分钟前
Python迭代器(Iterator)揭秘:for循环背后的故事
jvm·数据库·python
cm65432016 分钟前
Python字典与集合:高效数据管理的艺术
jvm·数据库·python
2401_8463416519 分钟前
Python单元测试(unittest)实战指南
jvm·数据库·python
CQU_JIAKE20 分钟前
3.23[Q]s
开发语言·windows·python
曲幽1 小时前
FastAPI单元测试实战:别等上线被喷才后悔,TestClient用对了真香!
python·单元测试·pytest·api·fastapi·web·httpx·testclient·依赖项覆盖