'Django / Heroku Deploying - ModuleNotFoundError: "No module named 'django'"

I get the ModuleNotFoundError: No module named 'django' if I deploy my Django-Project to Heroku. Does anyone know why that is?

The complete log file, which comes after opening, is attached. I've been searching for several hours, but can't solve it...

    2021-04-24T21:54:55.188701+00:00 heroku[web.1]: State changed from crashed to starting
    2021-04-24T21:54:59.835950+00:00 heroku[web.1]: Starting process with command `gunicorn MPLoadManagement.wsgi --log-file -`
    2021-04-24T21:55:02.907766+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [4] [INFO] Starting gunicorn 19.9.0
    2021-04-24T21:55:02.908183+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [4] [INFO] Listening at: http://0.0.0.0:3028 (4)
    2021-04-24T21:55:02.908277+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [4] [INFO] Using worker: sync
    2021-04-24T21:55:02.909677+00:00 app[web.1]: /app/.heroku/python/lib/python3.9/os.py:1023: RuntimeWarning: line buffering (buffering=1) isnt supported in binary mode, the default buffer size will be used
    2021-04-24T21:55:02.909678+00:00 app[web.1]: return io.open(fd, *args, **kwargs)
    2021-04-24T21:55:02.912935+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [7] [INFO] Booting worker with pid: 7
    2021-04-24T21:55:02.919805+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [7] [ERROR] Exception in worker process
    2021-04-24T21:55:02.919807+00:00 app[web.1]: Traceback (most recent call last):
    2021-04-24T21:55:02.919817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    2021-04-24T21:55:02.919818+00:00 app[web.1]: worker.init_process()
    2021-04-24T21:55:02.919818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 129, in init_process
    2021-04-24T21:55:02.919818+00:00 app[web.1]: self.load_wsgi()
    2021-04-24T21:55:02.919819+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    2021-04-24T21:55:02.919819+00:00 app[web.1]: self.wsgi = self.app.wsgi()
    2021-04-24T21:55:02.919820+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
    2021-04-24T21:55:02.919820+00:00 app[web.1]: self.callable = self.load()
    2021-04-24T21:55:02.919820+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    2021-04-24T21:55:02.919821+00:00 app[web.1]: return self.load_wsgiapp()
    2021-04-24T21:55:02.919821+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    2021-04-24T21:55:02.919821+00:00 app[web.1]: return util.import_app(self.app_uri)
    2021-04-24T21:55:02.919822+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 350, in import_app
    2021-04-24T21:55:02.919822+00:00 app[web.1]: __import__(module)
    2021-04-24T21:55:02.919823+00:00 app[web.1]: File "/app/MPLoadManagement/wsgi.py", line 12, in <module>
    2021-04-24T21:55:02.919823+00:00 app[web.1]: from django.core.wsgi import get_wsgi_application
    2021-04-24T21:55:02.919823+00:00 app[web.1]: ModuleNotFoundError: No module named 'django'
    2021-04-24T21:55:02.919969+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [7] [INFO] Worker exiting (pid: 7)
    2021-04-24T21:55:02.953092+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [4] [INFO] Shutting down: Master
    2021-04-24T21:55:02.953195+00:00 app[web.1]: [2021-04-24 21:55:02 +0000] [4] [INFO] Reason: Worker failed to boot.
    2021-04-24T21:55:03.019883+00:00 heroku[web.1]: Process exited with status 3
    2021-04-24T21:55:03.124137+00:00 heroku[web.1]: State changed from starting to crashed

Requirements.txt

appdirs==1.4.4
asgiref==3.3.1
astroid==2.5.2
beautifulsoup4==4.9.3
certifi==2020.12.5
distlib==0.3.1
dj-database-url==0.5.0
Django==3.1.7
django-autoslug==1.9.8
django-bootstrap-modal-forms==2.1.0
django-bootstrap4==2.3.1
django-crispy-forms==1.11.2
django-heroku==0.0.0
django-widget-tweaks==1.4.8
filelock==3.0.12
gunicorn==19.9.0
isort==5.8.0
lazy-object-proxy==1.6.0
mccabe==0.6.1
pipenv==2020.11.15
psycopg2-binary==2.8.6
pylint==2.7.4
pytz==2021.1
six==1.15.0
soupsieve==2.2.1
sqlparse==0.4.1
toml==0.10.2
virtualenv==20.4.4
virtualenv-clone==0.5.4
whitenoise==5.2.0
wrapt==1.12.1


Solution 1:[1]

In your requirements file change psycopg2-binary to just psycopg2

You are installing django-heroku==0.0.0 is that what you really want?

Solution 2:[2]

I've deployed more than 5 projects to Heroku and I have never faced like this error but it is obvious from the error message that Django is not installed probably, redeploy your project again and see if it works

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 periwinkle
Solution 2 Abdul Shakoor Mousa