Home > OS >  apache wsgi_mod fails to run on python 3.10
apache wsgi_mod fails to run on python 3.10

Time:01-17

I am developing a django app using django 4 and python 3.10. I had a server using apache and mod_wsgi, that used to run an old app using python3.8.

I've created a virtual env from 3.10. Command line manage.py is working well.

I've changed apache's conf:

WSGIDaemonProcess my_app310 python-path=/home/ubuntu/my_app310:/home/ubuntu/venv/my_app310/lib/python3.10/site-packages
WSGIProcessGroup my_app310
WSGIScriptAlias / /home/ubuntu/my_app310/my_app310/wsgi.py

But I keep getting:

[mpm_event:notice] AH00489: Apache/2.4.41 (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations
[core:notice] AH00094: Command line: '/usr/sbin/apache2'
[wsgi:error] mod_wsgi (pid=1724834): Failed to exec Python script file '/home/ubuntu/my_app310/my_app310/wsgi.py'.
[wsgi:error] mod_wsgi (pid=1724834): Exception occurred processing WSGI script '/home/ubuntu/my_app310/my_app310/wsgi.py'.
[wsgi:error]  Traceback (most recent call last):
[wsgi:error]     File "/home/ubuntu/venv/my_app310/lib/python3.10/site-packages/django/utils/timezone.py", line 10, in <module>
[wsgi:error]       import zoneinfo
[wsgi:error] ModuleNotFoundError: No module named 'zoneinfo'

Which suggest that something is running using python3.8 and not python3.10 (mod_wsgi?). What am I missing?

CodePudding user response:

WSGI Clearly says that File "/home/ubuntu/venv/my_app310/lib/python3.10/site-packages/django/utils/timezone.py", given this path has no module named zoneinfo try importing module into your python virtual environment. Example: pip install (module)

CodePudding user response:

If you use different versions of python for compiling mod_wsgi for Apache ( in your case 3.8 / 3.10) please see the comments in the mod _wsgi docs concerning the "--enable-shared" option.

https://modwsgi.readthedocs.io/en/master/user-guides/installation-issues.html#python-patch-level-mismatch

  •  Tags:  
  • Related