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?
2
Answers
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)
to configure apache2 with a certain Python Version just do the following:
you get an output like
you should see something like