No module named 'XXXXXXXX' in Django Heroku deployment - django

I am looking to make my first HEROKU deployment of a Django application, but I get the following error:
Traceback (most recent call last)
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError
at=error code=H10 desc="App crashed" method=GET path="/" host=temporalworld.herokuapp.com request_id=facb0a69-8362-4cea-99b1-152866e0487b fwd="146.112.251.213" dyno= connect= service= status=503 bytes= protocol=http
looks like i am missing a module. Is anybody familiar with this please?

0
I spent the day on it, and all i had to do was changing:
web: gunicorn core.wsgi --log-file=-
web: gunicorn my_app.wsgi
to
web: gunicorn core.wsgi --log-file=-
Basically removing the second line, and it worked.

Related

Heroku Application Error with Flask Socket-IO

The app is perfectly working on local but on heroku server it returns Application Error. I suspect the problem might be on Procfile, when I changed it to "web: gunicorn eventlet -w 1 app:app", from "web: gunicorn app:app" it stopped working, I'm new on socketIO and flask, I've tried everything I saw on the internet to put on Procfile that works with socketIO but nothing worked.
Please if anyone knows why this is happening please help me.
This is my requirements.txt file:
bidict==0.22.0
brotlipy==0.7.0
certifi==2021.10.8
click==8.1.3
dnspython==2.2.1
eventlet==0.33.1
Flask==2.1.3
Flask-SocketIO==5.2.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.0.1
gevent==21.12.0
gevent-websocket==0.10.1
greenlet==1.1.2
gunicorn==20.1.0
importlib-metadata==4.12.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
psycopg2==2.9.3
pycosat==0.6.3
python-engineio==4.3.3
python-socketio==5.7.1
SQLAlchemy==1.4.39
Werkzeug==2.1.2
wincertstore==0.2
WTForms==3.0.1
zipp==3.8.1
zope.event==4.5.0
zope.interface==5.4.0
this is the heroku logs:
2022-08-05T15:16:18.022704+00:00 app[web.1]:
2022-08-05T15:16:18.022716+00:00 app[web.1]: Error: class uri 'eventlet' invalid or not found:
2022-08-05T15:16:18.022716+00:00 app[web.1]:
2022-08-05T15:16:18.022717+00:00 app[web.1]: [Traceback (most recent call last):
2022-08-05T15:16:18.022717+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/util.py", line 99, in load_class
2022-08-05T15:16:18.022718+00:00 app[web.1]: mod = importlib.import_module('.'.join(components))
2022-08-05T15:16:18.022718+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-08-05T15:16:18.022718+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-08-05T15:16:18.022719+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2022-08-05T15:16:18.022719+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2022-08-05T15:16:18.022720+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2022-08-05T15:16:18.022720+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2022-08-05T15:16:18.022720+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2022-08-05T15:16:18.022721+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-08-05T15:16:18.022721+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/workers/geventlet.py", line 20, in <module>
2022-08-05T15:16:18.022721+00:00 app[web.1]: from eventlet.wsgi import ALREADY_HANDLED as EVENTLET_ALREADY_HANDLED
2022-08-05T15:16:18.022722+00:00 app[web.1]: ImportError: cannot import name 'ALREADY_HANDLED' from 'eventlet.wsgi' (/app/.heroku/python/lib/python3.10/site-packages/eventlet/wsgi.py)
2022-08-05T15:16:18.022722+00:00 app[web.1]: ]
2022-08-05T15:16:18.022722+00:00 app[web.1]:
2022-08-05T15:16:18.246442+00:00 heroku[web.1]: Process exited with status 1
2022-08-05T15:16:18.357952+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-05T15:16:18.374380+00:00 heroku[web.1]: State changed from crashed to starting
2022-08-05T15:16:23.365045+00:00 heroku[web.1]: Starting process with command `gunicorn -k eventlet -w 1 app:app`
2022-08-05T15:16:24.399378+00:00 app[web.1]:
2022-08-05T15:16:24.399392+00:00 app[web.1]: Error: class uri 'eventlet' invalid or not found:
2022-08-05T15:16:24.399392+00:00 app[web.1]:
2022-08-05T15:16:24.399393+00:00 app[web.1]: [Traceback (most recent call last):
2022-08-05T15:16:24.399393+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/util.py", line 99, in load_class
2022-08-05T15:16:24.399393+00:00 app[web.1]: mod = importlib.import_module('.'.join(components))
2022-08-05T15:16:24.399394+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-08-05T15:16:24.399394+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-08-05T15:16:24.399394+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2022-08-05T15:16:24.399395+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2022-08-05T15:16:24.399395+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2022-08-05T15:16:24.399395+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2022-08-05T15:16:24.399396+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2022-08-05T15:16:24.399396+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-08-05T15:16:24.399396+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/workers/geventlet.py", line 20, in <module>
2022-08-05T15:16:24.399397+00:00 app[web.1]: from eventlet.wsgi import ALREADY_HANDLED as EVENTLET_ALREADY_HANDLED
2022-08-05T15:16:24.399397+00:00 app[web.1]: ImportError: cannot import name 'ALREADY_HANDLED' from 'eventlet.wsgi' (/app/.heroku/python/lib/python3.10/site-packages/eventlet/wsgi.py)
2022-08-05T15:16:24.399398+00:00 app[web.1]: ]
2022-08-05T15:16:24.399402+00:00 app[web.1]:
2022-08-05T15:16:24.550505+00:00 heroku[web.1]: Process exited with status 1
2022-08-05T15:16:24.671364+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-05T15:31:37.077623+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/session" host=cheesecake142.herokuapp.com request_id=95dbcb95-8af7-42d6-8979-10d78af79447 fwd="120.29.69.149" dyno= connect= service= status=503 bytes= protocol=https
2022-08-05T15:31:37.460979+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cheesecake142.herokuapp.com request_id=0ca459b8-538a-47f9-a4b4-296e21540db8 fwd="120.29.69.149" dyno= connect=
service= status=503 bytes= protocol=https
I'm willing to provide additional details about this problem if needed.
So I had this exact issue myself just now, what worked for me in terms of getting rid of errors related to eventlet was specifying the python version (apparently python 3.2.0 is incompatible with the downgraded eventlet version, read eventlet issue 687). I still have other issues but they're unrelated so this might work for you:
create a runtime.txt file in root directory
in the file add python-3.9.13
Just to clarify my package versions:
bidict==0.22.0
CacheControl==0.12.11
cachetools==5.2.0
certifi==2022.6.15
cffi==1.15.1
charset-normalizer==2.1.0
click==8.1.3
colorama==0.4.5
dnspython==1.16.0
eventlet==0.30.2
firebase-admin==5.2.0
Flask==2.2.1
Flask-SocketIO==5.2.0
gevent==21.12.0
gevent-websocket==0.10.1
google-api-core==2.8.2
google-api-python-client==2.55.0
google-auth==2.10.0
google-auth-httplib2==0.1.0
google-cloud-core==2.3.2
google-cloud-firestore==2.6.0
google-cloud-storage==2.5.0
google-crc32c==1.3.0
google-resumable-media==2.3.3
googleapis-common-protos==1.56.4
greenlet==1.1.2
grpcio==1.47.0
grpcio-status==1.47.0
gunicorn==20.1.0
httplib2==0.20.4
idna==3.3
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
msgpack==1.0.4
proto-plus==1.20.6
protobuf==3.20.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pyparsing==3.0.9
python-decouple==3.6
python-dotenv==0.20.0
python-engineio==4.3.4
python-socketio==5.7.1
requests==2.28.1
rsa==4.9
six==1.16.0
uritemplate==4.1.1
urllib3==1.26.11
Werkzeug==2.2.1
zope.event==4.5.0
zope.interface==5.4.0
My Procfile:
web: gunicorn --worker-class eventlet -w 1 application:app
Hope this works!
Edit:
Forgot to clarify that dnspython has to be 1.16.0, your error in regards to that is due to the version not being lower than 2.0.0 - i still however after downgrading that to 1.16.0 got different errors which went away with the solution above
Try this:
pip install gunicorn==20.1.0 eventlet==0.30.2

Gettting the errror of my application can be served in heroku for django app

I am getting an error while deploying app on heroku
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Everything is working perfectly fine on heroku local
here are some of settings that I did
ALLOWED_HOSTS = ['0.0.0.0']
and here is Procfile
web: python manage.py runserver 0.0.0.0:$PORT
Here are my heroku logs
2022-07-10T16:25:15.788202+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2022-07-10T16:25:15.788202+00:00 app[web.1]:
2022-07-10T16:25:15.788210+00:00 app[web.1]: Traceback (most recent call last):
2022-07-10T16:25:15.788218+00:00 app[web.1]: File "/app/manage.py", line 22, in <module>
2022-07-10T16:25:15.788278+00:00 app[web.1]: main()
2022-07-10T16:25:15.788285+00:00 app[web.1]: File "/app/manage.py", line 18, in main
2022-07-10T16:25:15.788341+00:00 app[web.1]: execute_from_command_line(sys.argv)
2022-07-10T16:25:15.788349+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
2022-07-10T16:25:15.788475+00:00 app[web.1]: utility.execute()
2022-07-10T16:25:15.788483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
2022-07-10T16:25:15.788599+00:00 app[web.1]: self.fetch_command(subcommand).run_from_argv(self.argv)
2022-07-10T16:25:15.788606+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
2022-07-10T16:25:15.788717+00:00 app[web.1]: self.execute(*args, **cmd_options)
2022-07-10T16:25:15.788725+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 74, in execute
2022-07-10T16:25:15.788789+00:00 app[web.1]: super().execute(*args, **options)
2022-07-10T16:25:15.788797+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
2022-07-10T16:25:15.788909+00:00 app[web.1]: output = self.handle(*args, **options)
2022-07-10T16:25:15.788916+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 81, in handle
2022-07-10T16:25:15.788980+00:00 app[web.1]: if not settings.DEBUG and not settings.ALLOWED_HOSTS:
2022-07-10T16:25:15.788987+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__
2022-07-10T16:25:15.789055+00:00 app[web.1]: self._setup(name)
2022-07-10T16:25:15.789062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup
2022-07-10T16:25:15.789135+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2022-07-10T16:25:15.789142+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__
2022-07-10T16:25:15.789219+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2022-07-10T16:25:15.789226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-07-10T16:25:15.789298+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-07-10T16:25:15.789305+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2022-07-10T16:25:15.789371+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2022-07-10T16:25:15.789411+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2022-07-10T16:25:15.789450+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2022-07-10T16:25:15.789489+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2022-07-10T16:25:15.789535+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-07-10T16:25:15.789574+00:00 app[web.1]: File "/app/authentication/settings.py", line 98, in <module>
2022-07-10T16:25:15.789645+00:00 app[web.1]: 'NAME': env('DATABASE_NAME'),
2022-07-10T16:25:15.789652+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 197, in __call__
2022-07-10T16:25:15.789736+00:00 app[web.1]: return self.get_value(
2022-07-10T16:25:15.789743+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 407, in get_value
2022-07-10T16:25:15.789852+00:00 app[web.1]: raise ImproperlyConfigured(error_msg) from exc
2022-07-10T16:25:15.789898+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Set the DATABASE_NAME environment variable
2022-07-10T16:25:15.946054+00:00 heroku[web.1]: Process exited with status 1
2022-07-10T16:25:16.065755+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-10T16:25:16.070616+00:00 heroku[web.1]: State changed from crashed to starting
2022-07-10T16:25:20.000000+00:00 app[api]: Build succeeded
2022-07-10T16:25:20.067039+00:00 heroku[web.1]: Starting process with command `python manage.py runserver 0.0.0.0:37161`
2022-07-10T16:25:21.237371+00:00 app[web.1]: Traceback (most recent call last):
2022-07-10T16:25:21.237385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 403, in get_value
2022-07-10T16:25:21.237547+00:00 app[web.1]: value = self.ENVIRON[var_name]
2022-07-10T16:25:21.237555+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/os.py", line 679, in __getitem__
2022-07-10T16:25:21.237770+00:00 app[web.1]: raise KeyError(key) from None
2022-07-10T16:25:21.237797+00:00 app[web.1]: KeyError: 'DATABASE_NAME'
2022-07-10T16:25:21.237799+00:00 app[web.1]:
2022-07-10T16:25:21.237799+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2022-07-10T16:25:21.237799+00:00 app[web.1]:
2022-07-10T16:25:21.237802+00:00 app[web.1]: Traceback (most recent call last):
2022-07-10T16:25:21.237811+00:00 app[web.1]: File "/app/manage.py", line 22, in <module>
2022-07-10T16:25:21.237879+00:00 app[web.1]: main()
2022-07-10T16:25:21.237881+00:00 app[web.1]: File "/app/manage.py", line 18, in main
2022-07-10T16:25:21.237946+00:00 app[web.1]: execute_from_command_line(sys.argv)
2022-07-10T16:25:21.237953+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
2022-07-10T16:25:21.238093+00:00 app[web.1]: utility.execute()
2022-07-10T16:25:21.238101+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
2022-07-10T16:25:21.238231+00:00 app[web.1]: self.fetch_command(subcommand).run_from_argv(self.argv)
2022-07-10T16:25:21.238240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
2022-07-10T16:25:21.238392+00:00 app[web.1]: self.execute(*args, **cmd_options)
2022-07-10T16:25:21.238408+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 74, in execute
2022-07-10T16:25:21.238490+00:00 app[web.1]: super().execute(*args, **options)
2022-07-10T16:25:21.238492+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
2022-07-10T16:25:21.238623+00:00 app[web.1]: output = self.handle(*args, **options)
2022-07-10T16:25:21.238631+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 81, in handle
2022-07-10T16:25:21.238705+00:00 app[web.1]: if not settings.DEBUG and not settings.ALLOWED_HOSTS:
2022-07-10T16:25:21.238713+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__
2022-07-10T16:25:21.238787+00:00 app[web.1]: self._setup(name)
2022-07-10T16:25:21.238795+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup
2022-07-10T16:25:21.238865+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2022-07-10T16:25:21.238873+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__
2022-07-10T16:25:21.238981+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2022-07-10T16:25:21.238983+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-07-10T16:25:21.239083+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-07-10T16:25:21.239094+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2022-07-10T16:25:21.239164+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2022-07-10T16:25:21.239210+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2022-07-10T16:25:21.239272+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2022-07-10T16:25:21.239314+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2022-07-10T16:25:21.239367+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-07-10T16:25:21.239438+00:00 app[web.1]: File "/app/authentication/settings.py", line 98, in <module>
2022-07-10T16:25:21.239526+00:00 app[web.1]: 'NAME': env('DATABASE_NAME'),
2022-07-10T16:25:21.239528+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 197, in __call__
2022-07-10T16:25:21.239624+00:00 app[web.1]: return self.get_value(
2022-07-10T16:25:21.239633+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 407, in get_value
2022-07-10T16:25:21.239756+00:00 app[web.1]: raise ImproperlyConfigured(error_msg) from exc
2022-07-10T16:25:21.239777+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Set the DATABASE_NAME environment variable
2022-07-10T16:25:21.387335+00:00 heroku[web.1]: Process exited with status 1
2022-07-10T16:25:21.433687+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-10T16:25:22.244946+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=noorauth.herokuapp.com request_id=955f478f-323f-4a40-8fdc-38028f4f40b8 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:25:22.534127+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=noorauth.herokuapp.com request_id=7f6694f9-8224-46be-b742-c20078077222 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:26:01.095161+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=noorauth.herokuapp.com request_id=542f9404-c45a-4264-832f-f0e4db52408c fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:26:01.670778+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=noorauth.herokuapp.com request_id=a2e698a4-2547-4577-bc07-9b2d22293de5 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:29:59.391310+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=noorauth.herokuapp.com request_id=27902494-85e4-4f36-bbaa-89ae7e2895c2 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=http
2022-07-10T16:30:00.717408+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=noorauth.herokuapp.com request_id=17f3bab1-2105-4677-8b94-3c2a05456c04 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=http
The errors tells about the database name and everything that I have stored in .env file, what should I do, I can;t find ay help regarding the databses when deploying the app.
Your traceback is telling you that the 'DATABASE_NAME' environment variable has not been set, you can set that within your Heroku configuration.
https://devcenter.heroku.com/articles/config-vars
Another point is that your allowed hosts only has '0.0.0.0', you will need to include your Heroku app URL in there as well, or your custom URL if you are using a DNS provider.

Heroku Flask app crashes before it even starts [duplicate]

This question already has answers here:
Deploying 'Django for beginners' app to Heroku fails with ModuleNotFoundError: No module named '_tkinter'
(1 answer)
ModuleNotFoundError: No module named '_tkinter' Heroku
(4 answers)
"no module found: tkinter" after deploying in heroku
(1 answer)
Closed 8 months ago.
I get this error in my logs --tail
at=error code=H10 desc="App crashed" method=GET path="/" host=tsuyo-workout.herokuapp.com request_id=069bdbc7-cdb1-4d4e-8cc2-ec8dc55890f5 fwd="184.189.121.138" dyno= connect= service= status=503 bytes= protocol=https
At first I had my port set to 5000 as I was developing locally. I used this question to fix the h10 error. I still have the same error.
I fixed some other errors before this and they were:
Not having a Procfile. I added one.
Procfile:
web: gunicorn app:app
I fixed up my requirements.txt. I added gunicorn.
requirments.txt
click==8.0.3
Flask==2.0.2
itsdangerous==2.0.1
Jinja2==3.0.3
MarkupSafe==2.0.1
Werkzeug==2.0.3
gunicorn==20.0.4
I think the only relevant info in my app.py is this. Let me know if you need more:
app.py
app = Flask(__name__)
port = int(os.getenv('PORT'))
if __name__ == '__main__':
app.run(port=port)
I have a database in this app. Could it be the fact that I have a database?
Some more lines of errors per request.
2022-07-06T20:50:53.695436+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2022-07-06T20:50:53.695436+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-07-06T20:50:53.695437+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-07-06T20:50:53.695437+00:00 app[web.1]: self.callable = self.load()
2022-07-06T20:50:53.695437+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2022-07-06T20:50:53.695437+00:00 app[web.1]: return self.load_wsgiapp()
2022-07-06T20:50:53.695438+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2022-07-06T20:50:53.695438+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-07-06T20:50:53.695439+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2022-07-06T20:50:53.695439+00:00 app[web.1]: mod = importlib.import_module(module)
2022-07-06T20:50:53.695439+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2022-07-06T20:50:53.695440+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-07-06T20:50:53.695440+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2022-07-06T20:50:53.695440+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2022-07-06T20:50:53.695440+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2022-07-06T20:50:53.695441+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2022-07-06T20:50:53.695441+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 843, in exec_module
2022-07-06T20:50:53.695441+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2022-07-06T20:50:53.695441+00:00 app[web.1]: File "/app/app.py", line 5, in <module>
2022-07-06T20:50:53.695442+00:00 app[web.1]: from helper import message, get_db_connection, default, login_required
2022-07-06T20:50:53.695442+00:00 app[web.1]: File "/app/helper.py", line 2, in <module>
2022-07-06T20:50:53.695442+00:00 app[web.1]: from turtle import clear
2022-07-06T20:50:53.695443+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/turtle.py", line 107, in <module>
2022-07-06T20:50:53.695443+00:00 app[web.1]: import tkinter as TK
2022-07-06T20:50:53.695443+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/tkinter/__init__.py", line 36, in <module>
2022-07-06T20:50:53.695444+00:00 app[web.1]: import _tkinter # If this fails your Python may not be configured for Tk
2022-07-06T20:50:53.695444+00:00 app[web.1]: ModuleNotFoundError: No module named '_tkinter'
2022-07-06T20:50:53.695559+00:00 app[web.1]: [2022-07-06 20:50:53 +0000] [11] [INFO] Worker exiting (pid: 11)
2022-07-06T20:50:53.696450+00:00 app[web.1]: [2022-07-06 20:50:53 +0000] [10] [ERROR] Exception in worker process
2022-07-06T20:50:53.696451+00:00 app[web.1]: Traceback (most recent call last):
2022-07-06T20:50:53.696451+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2022-07-06T20:50:53.696452+00:00 app[web.1]: worker.init_process()
2022-07-06T20:50:53.696452+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2022-07-06T20:50:53.696452+00:00 app[web.1]: self.load_wsgi()
2022-07-06T20:50:53.696453+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2022-07-06T20:50:53.696453+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-07-06T20:50:53.696454+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-07-06T20:50:53.696454+00:00 app[web.1]: self.callable = self.load()
2022-07-06T20:50:53.696454+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2022-07-06T20:50:53.696454+00:00 app[web.1]: return self.load_wsgiapp()
2022-07-06T20:50:53.696455+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2022-07-06T20:50:53.696455+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-07-06T20:50:53.696455+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2022-07-06T20:50:53.696455+00:00 app[web.1]: mod = importlib.import_module(module)
2022-07-06T20:50:53.696456+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2022-07-06T20:50:53.696456+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-07-06T20:50:53.696457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2022-07-06T20:50:53.696457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2022-07-06T20:50:53.696457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2022-07-06T20:50:53.696458+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2022-07-06T20:50:53.696458+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 843, in exec_module
2022-07-06T20:50:53.696458+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2022-07-06T20:50:53.696459+00:00 app[web.1]: File "/app/app.py", line 5, in <module>
2022-07-06T20:50:53.696459+00:00 app[web.1]: from helper import message, get_db_connection, default, login_required
2022-07-06T20:50:53.696459+00:00 app[web.1]: File "/app/helper.py", line 2, in <module>
2022-07-06T20:50:53.696460+00:00 app[web.1]: from turtle import clear
2022-07-06T20:50:53.696462+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/turtle.py", line 107, in <module>
2022-07-06T20:50:53.696462+00:00 app[web.1]: import tkinter as TK
2022-07-06T20:50:53.696463+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/tkinter/__init__.py", line 36, in <module>
2022-07-06T20:50:53.696463+00:00 app[web.1]: import _tkinter # If this fails your Python may not be configured for Tk
2022-07-06T20:50:53.696463+00:00 app[web.1]: ModuleNotFoundError: No module named '_tkinter'
2022-07-06T20:50:53.696580+00:00 app[web.1]: [2022-07-06 20:50:53 +0000] [10] [INFO] Worker exiting (pid: 10)
2022-07-06T20:50:53.745546+00:00 app[web.1]: Traceback (most recent call last):
2022-07-06T20:50:53.745553+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 209, in run
2022-07-06T20:50:53.745765+00:00 app[web.1]: self.sleep()
2022-07-06T20:50:53.745775+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 357, in sleep
2022-07-06T20:50:53.745917+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2022-07-06T20:50:53.745927+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-07-06T20:50:53.746025+00:00 app[web.1]: self.reap_workers()
2022-07-06T20:50:53.746033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-07-06T20:50:53.746179+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-07-06T20:50:53.746222+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-07-06T20:50:53.746223+00:00 app[web.1]:
2022-07-06T20:50:53.746223+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-07-06T20:50:53.746223+00:00 app[web.1]:
2022-07-06T20:50:53.746230+00:00 app[web.1]: Traceback (most recent call last):
2022-07-06T20:50:53.746232+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2022-07-06T20:50:53.746304+00:00 app[web.1]: sys.exit(run())
2022-07-06T20:50:53.746306+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2022-07-06T20:50:53.746383+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2022-07-06T20:50:53.746398+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 228, in run
2022-07-06T20:50:53.746488+00:00 app[web.1]: super().run()
2022-07-06T20:50:53.746489+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 72, in run
2022-07-06T20:50:53.746561+00:00 app[web.1]: Arbiter(self).run()
2022-07-06T20:50:53.746563+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 229, in run
2022-07-06T20:50:53.746654+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2022-07-06T20:50:53.746656+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 342, in halt
2022-07-06T20:50:53.746772+00:00 app[web.1]: self.stop()
2022-07-06T20:50:53.746773+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 388, in stop
2022-07-06T20:50:53.746893+00:00 app[web.1]: limit = time.time() + self.cfg.graceful_timeout
2022-07-06T20:50:53.746894+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/config.py", line 57, in __getattr__
2022-07-06T20:50:53.746969+00:00 app[web.1]: return self.settings[name].get()
2022-07-06T20:50:53.746971+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-07-06T20:50:53.747058+00:00 app[web.1]: self.reap_workers()
2022-07-06T20:50:53.747068+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-07-06T20:50:53.747213+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-07-06T20:50:53.747235+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-07-06T20:50:53.882989+00:00 heroku[web.1]: Process exited with status 1
2022-07-06T20:50:53.927947+00:00 heroku[web.1]: State changed from up to crashed
2022-07-06T21:18:19.470130+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tsuyo-workout.herokuapp.com request_id=767ea937-4ad8-46f4-ad68-a8fa68f8c15b fwd="184.189.121.138" dyno= connect= service= status=503 bytes= protocol=https

ModuleNotFoundError: No module named 'phonenumbers'

I am deploying an app which works well locally to Heroku for the first time, and I have the following error:
ModuleNotFoundError: No module named 'phonenumbers'
2021-08-01T05:05:10.359150+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-08-01T05:05:10.359151+00:00 app[web.1]: django.setup(set_prefix=False)
2021-08-01T05:05:10.359151+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
2021-08-01T05:05:10.359152+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2021-08-01T05:05:10.359152+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
2021-08-01T05:05:10.359152+00:00 app[web.1]: app_config = AppConfig.create(entry)
2021-08-01T05:05:10.359153+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
2021-08-01T05:05:10.359153+00:00 app[web.1]: module = import_module(entry)
2021-08-01T05:05:10.359153+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2021-08-01T05:05:10.359154+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-08-01T05:05:10.359154+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2021-08-01T05:05:10.359155+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2021-08-01T05:05:10.359155+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
2021-08-01T05:05:10.359221+00:00 app[web.1]: ModuleNotFoundError: No module named 'phonenumbers'
2021-08-01T05:05:10.360272+00:00 app[web.1]: [2021-08-01 05:05:10 +0000] [9] [INFO] Worker exiting (pid: 9)
2021-08-01T05:05:10.416411+00:00 app[web.1]: [2021-08-01 05:05:10 +0000] [10] [ERROR] Exception in worker process
2021-08-01T05:05:10.416412+00:00 app[web.1]: Traceback (most recent call last):
2021-08-01T05:05:10.416413+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-08-01T05:05:10.416413+00:00 app[web.1]: worker.init_process()
2021-08-01T05:05:10.416414+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-08-01T05:05:10.416414+00:00 app[web.1]: self.load_wsgi()
2021-08-01T05:05:10.416415+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-08-01T05:05:10.416415+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-08-01T05:05:10.416419+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-08-01T05:05:10.416420+00:00 app[web.1]: self.callable = self.load()
2021-08-01T05:05:10.416420+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-08-01T05:05:10.416421+00:00 app[web.1]: return self.load_wsgiapp()
2021-08-01T05:05:10.416421+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-08-01T05:05:10.416421+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-08-01T05:05:10.416422+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 359, in import_app
2021-08-01T05:05:10.416422+00:00 app[web.1]: mod = importlib.import_module(module)
2021-08-01T05:05:10.416423+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2021-08-01T05:05:10.416423+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-08-01T05:05:10.416424+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2021-08-01T05:05:10.416424+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2021-08-01T05:05:10.416425+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2021-08-01T05:05:10.416425+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2021-08-01T05:05:10.416426+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2021-08-01T05:05:10.416426+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-08-01T05:05:10.416427+00:00 app[web.1]: File "/app/core/wsgi.py", line 13, in <module>
2021-08-01T05:05:10.416427+00:00 app[web.1]: application = get_wsgi_application()
When i try to install it phonenumbers again, it tells me that it is already installed.
I am quite new to Django/Python, coming from Ruby.
Is there a solution for this problem please ?
it works very well in development.
pip install django-phonenumber-field
pip install django-phonenumbers
I think you probably forgot to add 'phonenumbers' to INSTALLED_APP in settings.py
check on the bottom left on the tab phyton package that package. if not found
you have to make another phyton virtual environment.

I am trying to deploy my Django project to Heroku but an error regarding my SECRET_KEY keeps appearing

I am deploying an e-commerce project to Heroku and seem to be running into constant issues and errors.
My latest error surrounds the below traceback:
2019-11-11T13:35:34.080363+00:00 heroku[web.1]: State changed from crashed to starting
2019-11-11T13:35:40.020789+00:00 heroku[web.1]: Starting process with command `gunicorn fancyfetish.wsgi:application --preload --workers 1`
2019-11-11T13:35:42.589255+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-11T13:35:42.460008+00:00 app[web.1]: Traceback (most recent call last):
2019-11-11T13:35:42.460049+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2019-11-11T13:35:42.460136+00:00 app[web.1]: sys.exit(run())
2019-11-11T13:35:42.460148+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2019-11-11T13:35:42.460262+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2019-11-11T13:35:42.460273+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 219, in run
2019-11-11T13:35:42.460434+00:00 app[web.1]: super().run()
2019-11-11T13:35:42.460438+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
2019-11-11T13:35:42.460565+00:00 app[web.1]: Arbiter(self).run()
2019-11-11T13:35:42.460571+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 58, in __init__
2019-11-11T13:35:42.460689+00:00 app[web.1]: self.setup(app)
2019-11-11T13:35:42.460692+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 118, in setup
2019-11-11T13:35:42.460823+00:00 app[web.1]: self.app.wsgi()
2019-11-11T13:35:42.460827+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-11-11T13:35:42.460978+00:00 app[web.1]: self.callable = self.load()
2019-11-11T13:35:42.460981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2019-11-11T13:35:42.461083+00:00 app[web.1]: return self.load_wsgiapp()
2019-11-11T13:35:42.461087+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2019-11-11T13:35:42.461204+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-11-11T13:35:42.461207+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 331, in import_app
2019-11-11T13:35:42.461388+00:00 app[web.1]: mod = importlib.import_module(module)
2019-11-11T13:35:42.461392+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2019-11-11T13:35:42.461529+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-11-11T13:35:42.461542+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-11-11T13:35:42.461664+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-11-11T13:35:42.461737+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2019-11-11T13:35:42.461813+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2019-11-11T13:35:42.461888+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2019-11-11T13:35:42.461983+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2019-11-11T13:35:42.462061+00:00 app[web.1]: File "/app/fancyfetish/wsgi.py", line 17, in <module>
2019-11-11T13:35:42.462171+00:00 app[web.1]: application = get_wsgi_application()
2019-11-11T13:35:42.462176+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-11-11T13:35:42.462279+00:00 app[web.1]: django.setup(set_prefix=False)
2019-11-11T13:35:42.462298+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
2019-11-11T13:35:42.462381+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2019-11-11T13:35:42.462385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
2019-11-11T13:35:42.462516+00:00 app[web.1]: self._setup(name)
2019-11-11T13:35:42.462519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
2019-11-11T13:35:42.462637+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2019-11-11T13:35:42.462639+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 176, in __init__
2019-11-11T13:35:42.462783+00:00 app[web.1]: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2019-11-11T13:35:42.462808+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
2019-11-11T13:35:42.575764+00:00 heroku[web.1]: Process exited with status 1
2019-11-11T13:35:47.000000+00:00 app[api]: Build succeeded
2019-11-11T13:36:25.358883+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fancyfetish.herokuapp.com request_id=4f0e5e77-53c9-443a-8647-c5b88a01ae17 fwd="81.100.164.113" dyno= connect= service= status=503 bytes= protocol=https
2019-11-11T13:36:25.563374+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fancyfetish.herokuapp.com request_id=3828cca1-593c-4785-9c82-6b614c233dea fwd="81.100.164.113" dyno= connect= service= status=503 bytes= protocol=https
I have got three settings files under the directory settings, outlined below:
|____settings
| |______init__.py
| |____development.py
| |______pycache__
| | |____production.cpython-37.pyc
| | |____base.cpython-37.pyc
| | |____development.cpython-37.pyc
| | |______init__.cpython-37.pyc
| |____base.py
| |____production.py
|______init__.py
|______pycache__
| |____settings.cpython-37.pyc
| |____wsgi.cpython-37.pyc
| |____urls.cpython-37.pyc
| |______init__.cpython-37.pyc
|____urls.py
|____wsgi.py
All three of my settings files (base.py, development.py and production.py) have a SECRET_KEY defined so I am not sure why this error keeps appearing.
The SECRET_KEY is randomly generated. Is this to do with gunicorn?
My wsgi file looks like this:
import os
from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fancyfetish.settings')
application = get_wsgi_application()
(I am unsure if I even need to import from django.core.wsgi but this seemed to be someone elses solution, it didn't work for me)
My Procfile looks like this:
web: gunicorn fancyfetish.wsgi:application --preload --workers 1
My requirements.txt file looks like this:
beautifulsoup4==4.8.1
Django==2.2.6
django-appconf==1.0.3
django-bootstrap4==1.0.1
django-compressor==2.3
django-libsass==0.7
django-sass-processor==0.7.4
gunicorn==20.0.0
libsass==0.19.3
mysql-connector-python==8.0.18
Pillow==6.2.1
protobuf==3.10.0
pytz==2019.3
rcssmin==1.0.6
rjsmin==1.1.0
six==1.12.0
soupsieve==1.9.5
sqlparse==0.3.0
Is anyone able to see whay I am doing so wrong? Is it a compatibility issue between versions?
Try changing this line in your wsgi file:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fancyfetish.settings')
for this:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fancyfetish.settings.development') # or .production