欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

flask项目在vscode中启动调试的配置

程序员文章站 2022-06-22 18:18:15
...

使用vscode调试flask项目注意事项

setting.json中,配置venv(虚拟环境)路径:

{
    // "python.pythonPath": "/usr/local/opt/python3/bin/python3.6",
      // 以像素为单位控制字号。
    "editor.fontSize": 13,
      // Whether to lint Python files.
    "python.linting.enabled": false,
    "python.linting.pylintEnabled": true,
    "python.venvPath": "/venv",
    "python.pythonPath": "${workspaceFolder}/venv/bin/python",
}

在launch.json配置文件中,主要更改以下配置

{
    "name": "Python: Flask (0.11.x or later)",
    "type": "python",
    "request": "launch",
    "stopOnEntry": false,
    "pythonPath": "${config:python.pythonPath}",
    "program": "${workspaceRoot}/venv/bin/flask",
    // 以上需根据环境的实际路径修改
    "cwd": "${workspaceFolder}",
    "env": {
        "FLASK_APP": "${workspaceFolder}/run.py",
        "LC_ALL": "en_US.utf-8",
        "LANG":"en_US.utf-8"
    },
    "args": [
        "run",
        "--no-debugger",
        "--no-reload"
    ],
    "envFile": "${workspaceFolder}/.env",
    "debugOptions": [
         "RedirectOutput"
    ]
}