VS码调试器进口的错误,虽然在调试瓶中的应用程序

0

的问题

我现在有一个瓶中的应用程序中,文件的结构看起来是这样的:

C:\Users\kmelton\Python\Flask\BGSCS-API-dev\InterjectApi\server.py

和文件夹,我目前已开放作为一个工作空间VS码是BGSCS-API-dev文件夹。

我启动。json目前看起来像这样:

{
    // 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: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "server.py",
                "FLASK_ENV": "development"
            },
            "args": [
                "run",
                "--no-debugger"
            ],
            "jinja": true
        }
    ]
}

并在每一个调试,尝试,我得到一个错误。

 * Serving Flask app 'server.py' (lazy loading)
 * Environment: development
 * Debug mode: on
Usage: python -m flask run [OPTIONS]
Try 'python -m flask run --help' for help.

Error: Could not import 'server'.

我知道这有可能是我需要的东西添加到我的启动。json文件为道路的文件正确的,但事情我已经试过没有为我工作。 感谢

1

最好的答案

0

好了,所以我已经解决了最初的错误我是有的,只面临着一个新的错误有关的另一个进口问题,此时实际上内部的代码、进口文件,进口的现时运行程序正常进行。

修复我实现我的代码如下(内启动。json)

{
    // 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: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            # Added new line cwd to specify initial working directory
            "cwd":"${workspaceRoot}",
            "env": {
                # Added ${workspaceRoot}/InterjectApi/"file name trying to run"}
                "FLASK_APP": "${workspaceRoot}/InterjectApi/server.py",
                "FLASK_ENV": "development"
            },
            "args": [
                "run",
                "--no-debugger"
            ],
            "jinja": true
        }
    ]
}
2021-11-23 18:16:30

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................