Search code examples
pythonflaskherokupython-packaging

Multiple packages Python, Heroku not picking up Procfile file


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


Solution

  • 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