[Solved]-Mod_wsgi: Unable to stat Python home and ImportError: No module named 'encodings'


A couple of things to check.

  • The pyenv tool doesn’t install Python with a shared library by default. That could result in problems as mod_wsgi wants a shared library. You need to explicitly tell pyenv to build Python with a shared library.

  • A home directory on many Linux systems is not readable to other users. When mod_wsgi is being initialised, it is running as the Apache user and will not be able to see inside of the home directory. There isn’t an issue when the mod_wsgi module is loaded by Apache as Apache is running as root at that point.

There are other issues with your configuration where don’t follow best practices, but the above, especially the second item is likely the cause of your problem.

Leave a comment