I can run my flask app using python app.py
however if I try flask run
or flask shell
I get the following error:
(venv) C:\Users\Arrchana\PycharmProjects\ie-backend>flask run
* Serving Flask app "app.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "ie-backend.app", an ImportError was raised:
Traceback (most recent call last):
File "c:\users\arrchana\pycharmprojects\ie-backend\venv\lib\site-packages\flask\cli.py", line 240, in locate_app
__import__(module_name)
File "C:\Users\Arrchana\PycharmProjects\ie-backend\app.py", line 3, in <module>
from routes import api_dev
ModuleNotFoundError: No module named 'routes'
This is my application structure (some files and modules are missing):
ie-backend/
appInits/
__init__.py
dp.py
models/
__init__.py
user.py
app.py
config.py
routes.py
I have no issues importing config in app.py however, I get the ModuleNotFoundError when trying to import routes, appInits and models. I get the same error when I run flask shell
.
My app.py file looks like the following:
from flask import Flask
from config import Config
from flask_script import Manager
from flask_migrate import MigrateCommand
from routes import api_dev
from appInits.db import db
from appInits import jwt
from models.user import UserModel
app = Flask(__name__)
app.config.from_object(Config)
app.register_blueprint(api_dev, url_prefix='/dev')
db.init_app(app)
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
if __name__ == "__main__":
app.run(debug=Config.DEBUG)
I have no circular imports in routes, etc. My FLASK_APP=app.py.
run
that's not working? what do you get when you runflask shell
? – mkturnerflask shell
also results in the same error message – Arrchana