Closed juparker37 closed 3 months ago
The pythonpath with an entry where two consecutive directories carry the same name, and the one containing /bin/ (what?) makes me think you are launching gunicorn without chdir
or configuring venv
, yet the directories your import paths refer to are not part of your pythonpath.
The pythonpath with an entry where two consecutive directories carry the same name, and the one containing /bin/ (what?) makes me think you are launching gunicorn without
chdir
or configuringvenv
, yet the directories your import paths refer to are not part of your pythonpath.
Are you talking about the gunicorn.conf.py file with pythonpath? I am not using a venv as this project runs in the /home/ directory and global python is 3.11.
ls -la /home/jparker/.local/bin/
django-admin fonttools httpx mkdocs numpy-config pip3.11 pyftsubset watchmedo dotenv ghp-import jp.py mkdocs-get-deps pip pycache/ sqlformat wheel f2py gunicorn markdown_py normalizer pip3 pyftmerge ttx
python
Python 3.11.9 (main, Jun 19 2024, 10:02:06) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] on linux
>>> import django
>>> django
<module 'django' from '/home/jparker/.local/lib/python3.11/site-packages/django/__init__.py'>
Rebuilt project using VENV, issues resolved.
Hello:
I have been struggling for two days now to migrate from Django runserver to Gunicorn for production. I have read through the Guincorn settings and built a config file and I continue to get the error ModuleNotFoundError: No module named 'cloudmonitor.wsgi' even though the Django wsgi.py seems to be correct. I have tried to run "gunicorn -c gunicorn.conf.py cloudmonitor.wsgi:application" in /home/jparker/, /home/jparker/cloudmonitor, /home/jparker/cloudmonitor/cloudmonitor, even in the directory with manage.py as noted in https://docs.gunicorn.org/en/stable/run.html#django.
`[2024-08-15 15:42:09 +0000] [2454119] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/lib64/python3.11/logging/config.py", line 573, in configure handler = self.configure_handler(handlers[name]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/logging/config.py", line 757, in configure_handler result = factory(**kwargs) ^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/logging/handlers.py", line 155, in init BaseRotatingHandler.init(self, filename, mode, encoding=encoding, File "/usr/lib64/python3.11/logging/handlers.py", line 58, in init logging.FileHandler.init(self, filename, mode=mode, File "/usr/lib64/python3.11/logging/init.py", line 1181, in init StreamHandler.init(self, self._open()) ^^^^^^^^^^^^ File "/usr/lib64/python3.11/logging/init.py", line 1213, in _open return open_func(self.baseFilename, self.mode, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/opt/djangoprojects/reports/bin/gunicorn.errors'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker worker.init_process() File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/workers/base.py", line 135, in init_process self.load_wsgi() File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi self.wsgi = self.app.wsgi() ^^^^^^^^^^^^^^^ File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/app/base.py", line 66, in wsgi self.callable = self.load() ^^^^^^^^^^^ File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 57, in load return self.load_wsgiapp() ^^^^^^^^^^^^^^^^^^^ File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp return util.import_app(self.app_uri) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jparker/.local/lib/python3.11/site-packages/gunicorn/util.py", line 370, in import_app mod = importlib.import_module(module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/jparker/cloudmonitor/cloudmonitor/wsgi.py", line 13, in
application = get_wsgi_application()
^^^^^^^^^^^^^^^^^^^^^^
File "/home/jparker/.local/lib/python3.11/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/jparker/.local/lib/python3.11/site-packages/django/init.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/jparker/.local/lib/python3.11/site-packages/django/utils/log.py", line 76, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib64/python3.11/logging/config.py", line 823, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib64/python3.11/logging/config.py", line 580, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'gunicorn'
[2024-08-15 15:42:09 +0000] [2454119] [INFO] Worker exiting (pid: 2454119)
`
I have read countless Stackoverflow posts, Reddit, posted on Django forums and still unable to resolve the issue. I am wondering if this is a bug.
Below are the details of my Gunicron config file, Django wsgi.py, settings.py and environment information.
Environment information:
Django 5.1.0 Gunicorn 23.0.0 Nginx Reverse Proxy RHEL 8 Virtual Machine
`python -m pip show gunicorn
Name: gunicorn Version: 23.0.0 Summary: WSGI HTTP Server for UNIX Home-page: https://gunicorn.org Author: Author-email: Benoit Chesneau benoitc@gunicorn.org License: MIT Location: /home/jparker/.local/lib/python3.11/site-packages Requires: packaging Required-by: `
python -m pip show django Name: Django Version: 5.1 Summary: A high-level Python web framework that encourages rapid development and clean, pragmatic design. Home-page: https://www.djangoproject.com/ Author: Author-email: Django Software Foundation <foundation@djangoproject.com> License: BSD-3-Clause Location: /home/jparker/.local/lib/python3.11/site-packages Requires: asgiref, sqlparse Required-by: dj-database-url, django-cors-headers, django-filter, djangorestframework
gunicorn.conf.py
settings.py
wsgi.py