mod_wsgi-express causing ModuleNotFoundError: No module named "mod_wsgi.server"

Viewed 131

I'm trying to deploy the Django 3.2 project with Python 3.10 on CentOS 7 but I am facing issues in it. I'm trying to run the following command to run mod_wsgi-express:

mod_wsgi-express start-server  django_wsgi.py --server-root /var/www --user apache --group apache --port 80 --host XYZ

where XYZ is the IP of the machine i'm running this command on. I had to specify a different server root as my /tmp is noexec.

The contents of django_wsgi.py are:

import os
import sys
project_dir=os.path.dirname(__file__)
if project_dir not in sys.path:
    sys.path.append(project_dir)

from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'MY_PACKAGE_WHERE_SETTINGS_ARE.settings'
application = get_wsgi_application()

but I keep getting this error:


 [mpm_event:notice] [pid 101737:tid 139778434865344] AH00489: **Apache/2.4.52 (codeit) mod_wsgi/4.9.0 Python/3.10** configured -- resuming normal operations
 [core:notice] [pid 101737:tid 139778434865344] AH00094: Command line: 'httpd (mod_wsgi-express)  -f /var/www/httpd.conf -D MOD_WSGI_KEEP_ALIVE -D MOD_WSGI_WITH_LISTENER_HOST -D MOD_WSGI_MPM_ENABLE_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_WORKER_MODULE -D MOD_WSGI_MPM_EXISTS_PREFORK_MODULE -D FOREGROUND'

mod_wsgi (pid=101741): Exception occurred processing WSGI script '/var/www/handler.wsgi'.
 [wsgi:error] [pid 101741:tid 139778434865344] Traceback (most recent call last):
 [wsgi:error] [pid 101741:tid 139778434865344]   File "/var/www/handler.wsgi", line 7, in <module>
 [wsgi:error] [pid 101741:tid 139778434865344]     import mod_wsgi.server
 [wsgi:error] [pid 101741:tid 139778434865344] ModuleNotFoundError: No module named 'mod_wsgi.server'

The error says "handler.wsgi", I don't know if that is correct or it is not accepting my wsgi file ? When I tried opening a python console and tried to import "import mod_wsgi.serve", it showed no error.

Any help would be much appreciated because, I'm stuck on this for days.

0 Answers
Related