Home > Net >  Multiple packages Python, Heroku not picking up Procfile file
Multiple packages Python, Heroku not picking up Procfile file

Time:12-25

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

CodePudding user response:

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

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

CodePudding user response:

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
  • Related