0

So I am trying to set up my website online and it printed "Build succeeded" but when I tried entering the website I get this error: enter image description here

So I entered the command in the terminal and I had this error in my server:

File "/app/Server.py", line 1, in <module>
import requests

requests is included in requirements.txt I am not sure why I am getting this error Procfile:

web: gunicorn --bind 127.0.0.1:5000 Server:app

I am working with python, flask, Server.py is the file name and app = Flask(__name__)

full log error:

2020-04-29T22:00:54.375570+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-29T22:01:02.512425+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-29T22:01:02.199124+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-04-29T22:01:02.199914+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [4] [INFO] Listening at: http://127.0.0.1:5000 (4)
2020-04-29T22:01:02.200070+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [4] [INFO] Using worker: sync
2020-04-29T22:01:02.205899+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [9] [INFO] Booting worker with pid: 9
2020-04-29T22:01:02.231965+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [9] [ERROR] Exception in worker process
2020-04-29T22:01:02.231967+00:00 app[web.1]: Traceback (most recent call last):
2020-04-29T22:01:02.231990+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-04-29T22:01:02.231991+00:00 app[web.1]: worker.init_process()
2020-04-29T22:01:02.231991+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-04-29T22:01:02.231992+00:00 app[web.1]: self.load_wsgi()
2020-04-29T22:01:02.231992+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-04-29T22:01:02.231992+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-04-29T22:01:02.231993+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-04-29T22:01:02.231993+00:00 app[web.1]: self.callable = self.load()
2020-04-29T22:01:02.231993+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-04-29T22:01:02.231994+00:00 app[web.1]: return self.load_wsgiapp()
2020-04-29T22:01:02.231994+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-04-29T22:01:02.231994+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-04-29T22:01:02.231995+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2020-04-29T22:01:02.231995+00:00 app[web.1]: mod = importlib.import_module(module)
2020-04-29T22:01:02.231996+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-04-29T22:01:02.231996+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-04-29T22:01:02.231997+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-04-29T22:01:02.231997+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-04-29T22:01:02.231997+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-04-29T22:01:02.231998+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-04-29T22:01:02.231998+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-04-29T22:01:02.231998+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-04-29T22:01:02.231999+00:00 app[web.1]: File "/app/Server.py", line 2, in <module>
2020-04-29T22:01:02.231999+00:00 app[web.1]: import requests
2020-04-29T22:01:02.231999+00:00 app[web.1]: ModuleNotFoundError: No module named 'requests'
2020-04-29T22:01:02.234426+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [9] [INFO] Worker exiting (pid: 9)
2020-04-29T22:01:02.276833+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [10] [INFO] Booting worker with pid: 10
2020-04-29T22:01:02.288853+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [10] [ERROR] Exception in worker process
2020-04-29T22:01:02.288854+00:00 app[web.1]: Traceback (most recent call last):
2020-04-29T22:01:02.288855+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-04-29T22:01:02.288856+00:00 app[web.1]: worker.init_process()
2020-04-29T22:01:02.288856+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-04-29T22:01:02.288856+00:00 app[web.1]: self.load_wsgi()
2020-04-29T22:01:02.288857+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-04-29T22:01:02.288857+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-04-29T22:01:02.288858+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-04-29T22:01:02.288858+00:00 app[web.1]: self.callable = self.load()
2020-04-29T22:01:02.288859+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-04-29T22:01:02.288859+00:00 app[web.1]: return self.load_wsgiapp()
2020-04-29T22:01:02.288859+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-04-29T22:01:02.288860+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-04-29T22:01:02.288860+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2020-04-29T22:01:02.288861+00:00 app[web.1]: mod = importlib.import_module(module)
2020-04-29T22:01:02.288861+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-04-29T22:01:02.288861+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-04-29T22:01:02.288862+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-04-29T22:01:02.288862+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-04-29T22:01:02.288863+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-04-29T22:01:02.288863+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-04-29T22:01:02.288863+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-04-29T22:01:02.288864+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-04-29T22:01:02.288864+00:00 app[web.1]: File "/app/Server.py", line 2, in <module>
2020-04-29T22:01:02.288864+00:00 app[web.1]: import requests
2020-04-29T22:01:02.288865+00:00 app[web.1]: ModuleNotFoundError: No module named 'requests'
2020-04-29T22:01:02.289094+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-04-29T22:01:02.400999+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [4] [INFO] Shutting down: Master
2020-04-29T22:01:02.401112+00:00 app[web.1]: [2020-04-29 22:01:02 +0000] [4] [INFO] Reason: Worker failed to boot.

enter image description here

Patch
  • 694
  • 1
  • 10
  • 29
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/212826/discussion-on-question-by-patch-heroku-codeh10-error-at-the-first-line). – Samuel Liew Apr 30 '20 at 03:50

1 Answers1

1

So the first problem was that I needed to install all of the modules to Pipfile(all the modules in the project). for some reason, my requirements.txt didn't go through if you insist to know why it doesn't work try to read A question about it(maybe re-modify it). the second problem was on my end: I put my program in def main() which you can not do as @mechanical_meat said "app needs to be available at the top level of the module"

Patch
  • 694
  • 1
  • 10
  • 29