0

i'm trying for hours to deploy a django app on an apache2 and still get following error:

  PYTHONHOME = '/home/rickmanns/bar/bar/djenv'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/home/rickmanns/bar/bar/djenv/lib/python3.11'
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/home/rickmanns/bar/bar/djenv'
  sys.base_exec_prefix = '/home/rickmanns/bar/bar/djenv'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/home/rickmanns/bar/bar/djenv'
  sys.exec_prefix = '/home/rickmanns/bar/bar/djenv'
  sys.path = [
    '/home/rickmanns/bar/bar/djenv/lib/python311.zip',
    '/home/rickmanns/bar/bar/djenv/lib/python3.11',
    '/home/rickmanns/bar/bar/djenv/lib/python3.11/lib-dynload',
  ]
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'

My Apache config looks like following:

    Alias /static /home/rickmanns/bar/static
    <Directory /home/user/myproject/static>
            Require all granted
    </Directory>

    <Directory /home/rickmanns/bar/bar>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    WSGIDaemonProcess bar python-path=/home/rickmanns/bar python-home=/home/rickmanns/bar/djenv
    WSGIProcessGroup bar
    WSGIScriptAlias / /home/rickmanns/bar/bar/wsgi.py

If it's helpful - i followed this tutorial: https://pimylifeup.com/raspberry-pi-django/

Thanks to everyone!

1 Answer 1

0

Your venv seems to be in /home/rickmanns/bar/bar/djenv/, but you declare the python-home as /home/rickmanns/bar/djenv.

Generally, that error points to an issue with the python home: https://discuss.python.org/t/fatal-python-error-init-fs-encoding-failed-to-get-the-python-codec-of-the-filesystem-encoding/3173/2

Try:

WSGIDaemonProcess bar python-path=/home/rickmanns/bar python-home=/home/rickmanns/bar/bar/djenv

Might have to check the python-path as well, depending on your project structure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.