0

Was able to create a working Django application and works fine in development (runserver). However, I'm currently stuck with my production build using Apache as the web server. Hope someone can help.

Have added the following lines in my httpd.conf file:

# ServerName localhost:80 # use this if you're running this on a VirtualBox VM or PC
ServerName localhost:8000

# Django Project
LoadFile "C:/Users/Anton/AppData/Local/Programs/Python/Python310/python310.dll"
LoadModule wsgi_module "C:/Users/Anton/Documents/Dad/PythonVirtual/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win_amd64.pyd"

WSGIPythonHome "C:/Users/Anton/Documents/Dad/PythonVirtual"
WSGIPythonPath "C:/Users/Anton/Documents/Dad/Complere"

WSGIScriptAlias / "C:/Users/Anton/Documents/Dad/Complere/Complere/wsgi.py"
<Directory "C:/Users/Anton/Documents/Dad/Complere/Complere/">
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

Alias /static/ "C:/Users/Anton/Documents/Dad/Complere/static/"
<Directory "C:/Users/Anton/Documents/Dad/Complere/static/">
    Require all granted

`

Without the additional lines mentioned above, I can see the apache service running in background. However, once above lines have been added, the apache server is in stopped status. Below is the log file content.

Starting the 'Apache2.4' service
The 'Apache2.4' service is running.
pm_winnt:notice] [pid 8692:tid 408] AH00455: Apache/2.4.54 (Win64) mod_wsgi/4.9.4 Python/3.10  configured -- resuming normal operations
[Mon Nov 07 22:01:09.941909 2022] [mpm_winnt:notice] [pid 8692:tid 408] AH00456: Apache Lounge  VS16 Server built: Jun 22 2022 09:58:15
[Mon Nov 07 22:01:09.941909 2022] [core:notice] [pid 8692:tid 408] AH00094: Command line:    'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Mon Nov 07 22:01:09.945903 2022] [mpm_winnt:notice] [pid 8692:tid 408] AH00418: Parent: Created    child process 6552
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\Apache24\\bin\\httpd.exe'
  sys.base_prefix = 'C:\\Users\\Anton\\AppData\\Local\\Programs\\Python\\Python310'
  sys.base_exec_prefix = 'C:\\Users\\Anton\\AppData\\Local\\Programs\\Python\\Python310'
  sys.platlibdir = 'lib'
  sys.executable = 'C:\\Apache24\\bin\\httpd.exe'
  sys.prefix = 'C:\\Users\\Anton\\AppData\\Local\\Programs\\Python\\Python310'
  sys.exec_prefix = 'C:\\Users\\Anton\\AppData\\Local\\Programs\\Python\\Python310'
  sys.path = [
    'C:\\Users\\Anton\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
    '.\\DLLs',
    '.\\lib',
    'C:\\Apache24\\bin',`
  ]

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000156c (most recent call first): [Mon Nov 07 22:01:10.411286 2022] [mpm_winnt:crit] [pid 8692:tid 408] AH00419: master_main: create child process failed. Exiting. ` ``


JPC
  • 1
  • 2
  • Found the answer here - https://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings – JPC Dec 28 '22 at 11:18

0 Answers0