Skip to content

Flask debugger configuration fails (Window) with "could not import" message #1634

@kraigb

Description

@kraigb

2018.4.0 release.
Windows 10

Also reported as microsoft/vscode#48972.

Repro steps:

  1. Create a "hello.py" with code like the following:
    from flask import Flask
    app = Flask(__name__)

    @app.route('/')
    def hello_flask():    
        return '<html><body>Hello, <strong>Flask</strong>!</body></html>'

    if __name__ == '__main__':
        app.run('localhost', 5555)
  1. Run the app under the Python: Current File configuration. Result: success.
  2. Run the app under the Python: Flask configuration. Result:
    D:\py\Flask>cd d:\py\Flask && cmd /C "set "FLASK_APP=D:\py\Flask/app.py" &&     set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" &&     d:\py\Flask\env\Scripts\python.exe
    C:\Users\kraigb\.vscode\extensions\ms-python.python-2018.4.0\pythonFiles\PythonTools\visualstudio_py_launcher.py d:\py\Flask 64579 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput -m flask run --no-debugger --no-reload "
     * Serving Flask app "D:\py\Flask/app.py"
     * Environment: production
       WARNING: Do not use the development server in a production environment.
       Use a production WSGI server instead.
     * Debug mode: off
    Usage: python -m flask run [OPTIONS]

    Error: Could not import "D".

Seems like a problem parsing the path.

Metadata

Metadata

Assignees

Labels

area-debuggingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions