I installed gunicorn inside virtual environment for running a django project in Ubutu 22 and tried to bind the project URL. But the below error appear and I am not able to bind. Can anybody please help me fix this error. Thanks
python --version
Python 3.10.12
(venv_django_proj) django@ubuntu-Virtual-Machine:~/django_proj/django_proj$ gunicorn django_proj.wsgi
[2024-02-19 18:59:13 +0530] [25811] [INFO] Starting gunicorn 20.1.0
[2024-02-19 18:59:13 +0530] [25811] [INFO] Listening at: http://127.0.0.1:8000 (25811)
[2024-02-19 18:59:13 +0530] [25811] [INFO] Using worker: sync
[2024-02-19 18:59:13 +0530] [25812] [INFO] Booting worker with pid: 25812
[2024-02-19 18:59:13 +0530] [25812] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 384, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/django/django_proj/django_proj/django_proj/wsgi.py", line 12, in <module>
from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
[2024-02-19 18:59:13 +0530] [25812] [INFO] Worker exiting (pid: 25812)
[2024-02-19 18:59:13 +0530] [25811] [INFO] Shutting down: Master
[2024-02-19 18:59:13 +0530] [25811] [INFO] Reason: Worker failed to boot.
2
Answers
Thanks everybody... I reinstalled both django and gunicorn in the virtual environment and now it is working... Thanks..
You did not installed
Django
to your virtual enviroment. Install Django and other required packages for your project.You can install django using this command:
pip install django