Skip to content
Advertisement

flask.cli.NoAppException: Could not import “app”

JavaScript

My application’s name is app.py, and it’s in a folder named ToDo-App, and within this folder there is another folder called templates, that contains the index.html file.

JavaScript

In the terminal:

Esam@DESKTOP-73QDAD3 MINGW32 /i/web/advanced-track/1-sql_and_data_modeling_for_the_web/ToDo-App
$ FLASK_APP=app.py FLASK_DEBUG=true flask run

  • Serving Flask app “app.py” (lazy loading)
  • Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Debug mode: on
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 266-552-216
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

When I opened this link http://127.0.0.1:5000/

Traceback (most recent call last): File “C:UsersEsamAppDataLocalProgramsPythonPython39-32Libsite-packagesflaskcli.py”, line 236, in locate_app import(module_name) ModuleNotFoundError: No module named ‘app’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:UsersEsamAppDataLocalProgramsPythonPython39-32Libsite-packagesflaskcli.py”, line 337, in call rv = self._load_unlocked() File “C:UsersEsamAppDataLocalProgramsPythonPython39-32Libsite-packagesflaskcli.py”, line 324, in _load_unlocked self._app = rv = self.loader() File “C:UsersEsamAppDataLocalProgramsPythonPython39-32Libsite-packagesflaskcli.py”, line 381, in load_app app = locate_app(self, import_name, name) File “C:UsersEsamAppDataLocalProgramsPythonPython39-32Libsite-packagesflaskcli.py”, line 246, in locate_app raise NoAppException( flask.cli.NoAppException: Could not import “app”.

Advertisement

Answer

Depend on what machine your using, you need to do one of the following:

Unix Bash (Linux, Mac, etc.):

JavaScript

Windows CMD:

JavaScript

Windows PowerShell:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement