I'm trying to switch a django site from running in python 3.6 to python 3.7 on Ubuntu 16.04. To do so I created a new environment in the same path as the old and have re-installed all of the dependencies.
The Apache server, however, fails with the following error:
Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'
Which error, after a bit of research, seems to be due to the WSGI configuration, as per:
You cannot for example force mod_wsgi to use a Python virtual environment created using Python 3.5 when mod_wsgi was originally compiled for Python 2.7. This is because the Python library for the Python installation it was originally compiled against is linked directly into the mod_wsgi module. In other words, Python is embedded within mod_wsgi. When mod_wsgi is used it does not run the command line python program to run the interpreter and thus why you can’t force it to use a different Python installation.
from: https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html
thanks to: Django Apache wsgi changes python version
The OP in the above ended up just wiping the setup clean and starting from scratch. This seems a bit extreme to me, as it seems like I should just be able to re-install/re-configure mod-wsgi to run with python3.7
In this line of thinking, I uninstalled and reinstalled both, libapache2-mod-wsgi-py3 and mod_wsgi. The former, however, just reconfigures to 3.6 automatically, as seen below:
root@server1:~# dpkg -S mod_wsgi
libapache2-mod-wsgi-py3: /usr/lib/apache2/modules/mod_wsgi.so
libapache2-mod-wsgi-py3: /usr/lib/apache2/modules/mod_wsgi.so-3.6
and the mod_wsgi installation fails with:
RuntimeError: The 'apxs' command appears not to be installed or is not executable.
How can I re-build wsgi with python 3.7?