0

I am working on a python Flask project with multiple packages. The folder structure is as follows:

root
|--programs
   |--package_1
      |--__init__.py
      |--app.py
   |--package_2
      |--__init__.py
      |--pythonfiles2.py
   |--package_2
      |--__init__.py
      |--pythonfiles3.py
   |--main.py
   |--.env
|--docs
|--requirements.txt
|--runtime.txt
|--Procfile

I am hosting the project on Heroku, and the main.py file is as follows:

from package_1.app import flask_app

if __name__ == "__main__":
   flask_app.run(debug=True)

As can be seen above, I initialise flask_app in one of the packages and then import it into the main file. Further, the Procfile for the project is situated in the programs directory.

However, when I deploy the application I get this error: No web processes running

Does anyone know what's going wrong?

Thank you!

Edit: the Procfile contains: web gunicorn programs.main:flask_app

2 Answers2

0

Have you tried $ heroku ps:scale web=1 ?

If that didn't work can you please share your Procfile ?

  • I have tried that, with regards to this post: https://stackoverflow.com/questions/41804507/h14-error-in-heroku-no-web-processes-running ... still no luck! Also, just shared Procfile – Harry Duffy Dec 25 '21 at 06:54
  • Are the colon and space in Procfile in the right place? Even those can create problems. Maybe try to paste this in your Procfile instead `web: gunicorn main:app` and place your `main.py` file in the same directory as Procfile and `requirements.txt`. – Omnipotent94 Dec 26 '21 at 07:57
0

The reason it wasn't working was because of the location of the .env file. I needed, counter-intuitively, to store the .env file outside the programs directory.

That is, the new folder structure is:

root
|--programs
   |--package_1
      |--__init__.py
      |--app.py
   |--package_2
      |--__init__.py
      |--pythonfiles2.py
   |--package_2
      |--__init__.py
      |--pythonfiles3.py
   |--main.py
|--docs
|--requirements.txt
|--runtime.txt
|--Procfile
|--.env
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83