Search code examples
pythonflaskflask-sqlalchemypython-module

ModuleNotFoundError: Flask


  • I am calling a module inside urbancloth package from home.py
  • This runs the __init__ file but doesn't run another module present in urbancloth.

  • The directory structure is as follows - enter image description here

  • The code in home.py:

from urbancloth import app


if __name__ == '__main__':
    app.run(debug =True)
  • The code in __init__.py:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SECRET_KEY'] = 'b0fe7021532f0541f87226aafd71ec77'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)


from urbancloth import routes

and the error message is- enter image description here

I am following Sir CoreySchafers Flask tutorials

Github for original code


Solution

  • If you will look at you error closely from urabncloth import app

    Looking at your directory there is no urabncloth it is urbancloth. Just a typo.
    So in your routes.py change the package name.

    Hope this solves your problem!!!