Skip to content Skip to sidebar Skip to footer

Mod_wsgi - Fatal Python Error: Initfsencoding: Unable To Load The File System Codec

Using Red Hat, apache 2.4.6, worker mpm, mod_wsgi 4.6.5, and Python 3.7 When I start httpd I get the above error and: ModuleNotFoundError: No module named 'encodings' In the httpd

Solution 1:

As I ran into this problem recently, I found a solution that works in my environment.
I don't work with a virtual environment, but have a non-standard python installation in my home folder (compiled and installed without root access) - this should be similar to a virtual environment.

My virtual host config is structured as follows:

WSGIPythonHome /home/myuser/usr/
<VirtualHost *:80>
    ...
    WSGIDaemonProcess wsgi home=/path/to/my/project/folder processes=10 threads=10
    WSGIScriptAlias / /path/to/my/project/folder/wsgi.py
    WSGIProcessGroup wsgi
</VirtualHost>

First, I omitted python-path completely. Further, WSGIPythonHome should point to the parent folder of the bin/, lib/ and include/ directories with the python libraries. I made the mistake to point it towards the bin/ folder. Consequentially, WSGI could not load the default libraries, even when I added them to the python path manually via WSGIPythonPath.


Solution 2:

I had a very similar issue and I found that my manually specified LoadModule wsgi_module "/path_to_conda/" was being ignored because the previously apache-wide wsgi mod was being loaded. You can check if wsgi.* is present in /etc/apache2/mods-enabled.

If that is the case, consider a2dismod wsgi to disable the apache wsgi that loads the wrong python.


Post a Comment for "Mod_wsgi - Fatal Python Error: Initfsencoding: Unable To Load The File System Codec"