[Python] ModuleNotFoundError: No module named 'flask'

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    After reading title of this post, don't try to make duplicate first because herewith content may be asked in different way. Btw, I'm very new in python and start learning now for work requirement.

    here are my dependencies

    virtualenv --version => 15.0.2

    pip --version => 19.0.3

    flask --version => 1.0.2, Python 2.7.10 (default, Aug 17 2018, 19:45:58)

    python --version => 3.7.1

    And, here is my source code of main.py

    from flask import Flask
    app = Flask(__name__)

    @app.route("/")
    def home():
    return "Hello, World!"


    Problem is following error encountered when I render like python main.py


    Traceback (most recent call last): File "main.py", line 1, in from flask import Flask ModuleNotFoundError: No module named 'flask'
    ​

    But when I render like FLASK_APP=main.py flask run, it was working. Please let me know how's difference between python ... and FLASH_APP= ...

    Continue reading...

Compartilhe esta Página