bradtraversy / lead_manager_react_django

Full stack app with React, Redux & Django
592 stars 316 forks source link

ModuleNotFoundError: No module named 'App Name' when using Django and Gunicorn on a heroku server #26

Open abinpaulr9747 opened 4 years ago

abinpaulr9747 commented 4 years ago

What I am trying to do here is setup a sample django app in heroku server. When running the app with gunicorn I get this error

This is what's in the log.

2020-02-14T12:11:30.549141+00:00 heroku[web.1]: State changed from crashed to starting 2020-02-14T12:11:41.607618+00:00 heroku[web.1]: Starting process with commandgunicorn leadmanager.wsgi --log-file -` 2020-02-14T12:11:44.346394+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [4] [INFO] Starting gunicorn 20.0.4 2020-02-14T12:11:44.347348+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [4] [INFO] Listening at: http://0.0.0.0:54007 (4) 2020-02-14T12:11:44.347349+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [4] [INFO] Using worker: sync 2020-02-14T12:11:44.351554+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [10] [INFO] Booting worker with pid: 10 2020-02-14T12:11:44.359278+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [11] [INFO] Booting worker with pid: 11 2020-02-14T12:11:45.104994+00:00 heroku[web.1]: State changed from starting to crashed 2020-02-14T12:11:44.664943+00:00 app[web.1]: [2020-02-14 12:11:44 +0000] [11] [ERROR] Exception in worker process 2020-02-14T12:11:44.664951+00:00 app[web.1]: Traceback (most recent call last): 2020-02-14T12:11:44.664953+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2020-02-14T12:11:44.664953+00:00 app[web.1]: worker.init_process() 2020-02-14T12:11:44.664954+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process 2020-02-14T12:11:44.664954+00:00 app[web.1]: self.load_wsgi() 2020-02-14T12:11:44.664955+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi 2020-02-14T12:11:44.664955+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2020-02-14T12:11:44.664955+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 2020-02-14T12:11:44.664956+00:00 app[web.1]: self.callable = self.load() 2020-02-14T12:11:44.664956+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load 2020-02-14T12:11:44.664957+00:00 app[web.1]: return self.load_wsgiapp() 2020-02-14T12:11:44.664957+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp 2020-02-14T12:11:44.664957+00:00 app[web.1]: return util.import_app(self.app_uri) 2020-02-14T12:11:44.664958+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app 2020-02-14T12:11:44.664959+00:00 app[web.1]: mod = importlib.import_module(module) 2020-02-14T12:11:44.664959+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/init.py", line 127, in import_module 2020-02-14T12:11:44.664961+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2020-02-14T12:11:44.664961+00:00 app[web.1]: File "", line 1006, in _gcd_import 2020-02-14T12:11:44.664962+00:00 app[web.1]: File "", line 983, in _find_and_load 2020-02-14T12:11:44.664962+00:00 app[web.1]: File "", line 967, in _find_and_load_unlocked 2020-02-14T12:11:44.664962+00:00 app[web.1]: File "", line 677, in _load_unlocked 2020-02-14T12:11:44.664963+00:00 app[web.1]: File "", line 728, in exec_module 2020-02-14T12:11:44.664963+00:00 app[web.1]: File "", line 219, in _call_with_frames_removed 2020-02-14T12:11:44.664964+00:00 app[web.1]: File "/app/leadmanager/wsgi.py", line 16, in 2020-02-14T12:11:44.664964+00:00 app[web.1]: application = get_wsgi_application() 2020-02-14T12:11:44.664964+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2020-02-14T12:11:44.664965+00:00 app[web.1]: django.setup(set_prefix=False) 2020-02-14T12:11:44.664965+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/init.py", line 24, in setup 2020-02-14T12:11:44.664966+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS) 2020-02-14T12:11:44.664966+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate 2020-02-14T12:11:44.664966+00:00 app[web.1]: app_config = AppConfig.create(entry) 2020-02-14T12:11:44.664967+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create 2020-02-14T12:11:44.664967+00:00 app[web.1]: module = import_module(entry) 2020-02-14T12:11:44.664967+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/init.py", line 127, in import_module 2020-02-14T12:11:44.664968+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2020-02-14T12:11:44.664968+00:00 app[web.1]: File "", line 1006, in _gcd_import 2020-02-14T12:11:44.664969+00:00 app[web.1]: File "", line 983, in _find_and_load 2020-02-14T12:11:44.664969+00:00 app[web.1]: File "", line 965, in _find_and_load_unlocked 2020-02-14T12:11:44.664970+00:00 app[web.1]: ModuleNotFoundError: No module named 'leads'

In the settings.py I am including the apps like this

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'whitenoise.runserver_nostatic', 'rest_framework', 'leads', 'frontend', 'knox', 'accounts' ]

Below is my folder structure TzcBj

I am new to django Please help as I have found no solution for this with my limited knowledge and hours of browsing

san425 commented 3 years ago

Same! Somebody help us! I've been on this for almost 2 days now.

san425 commented 3 years ago

Have you fixed it yet? If yes, how?

san425 commented 3 years ago

Hahaha! This is a very silly mistake, at least I think it is. But you should check the ".gitignore" file. If you used the template 'Python' Github will ignore it causing Heroku to not pull the app from Github. I spent a whole week trying to fix this. 🤦‍♂️

san425 commented 3 years ago

Btw, to fix it, either delete the file or just change the template to the proper one. Your app must consist of something other than the Template.