I\'m trying to deploy a Flask app to Heroku. After deploying, application crashes and I get an error ModuleNotFoundError: No module named \'app\'.
Project structure
web:gunicorn app:app
is standard Procfile. It expects that your .py file should be named app.py.
If you want to change .py name you should change Procfile as well.
web:gunicorn my_app_name:app
After that you can name your file - my_app_name.py
On your local machine, at the base of your repository, you need to add a Procfile (exactly like this).
Inside that, paste only one line: web: gunicorn :app
Example: If you want to trigger init.py, then:
web: gunicorn init:app
In my case, this was resolved after I made the following changes, of course committing the changes before pushing to heroku:
1) ran pip freeze > requirements.txt
,
2) moved my app.py
to a different directory, and updated Procfile
, manage.py
-all files importing app.py- and to reflect the new location. I'm not sure if moving the file actually made a difference, it seems unlikely, but regardless, it's worth verifying all files that import app
have the correct path