Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

430
Visualizações
Apache, Django and wsgi, No module named 'encodings'

I've looked through many stack overflow questions with the same issues, but none of them solved my issue. I'm trying to deploy Django on AWS - Ubuntu 18.04 using Apache and WSGI.

When running my website with Django's servers on port 8000, everything works fine. Then when I attempt to run on apache I get the following error in my logs.

Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
Command line: '/usr/sbin/apache2'
(2)No such file or directory: mod_wsgi: Unable to stat Python home /var/www/html/projects/venv
Python interpreter may not be able to be initialized correctly. Verify the supplied path
and access permissions for whole of the path.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

As it says clearly mod_wsgi and Python 3 are configured. I am using a virtual environment. My project is located at:

/var/www/html/project/venv/mysite

My Apache conf file is configured as:

<Directory /var/www/html/projects/venv/mysite/mysite>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess mysite python-path=/var/www/html/projects/venv/mysite python-home =/var/www/html/projects/venv
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/html/projects/venv/mysite/mysite/wsgi.py

Alias /static /var/www/html/projects/venv/mysite/polls/static
<Directory /var/www/html/projects/venv/mysite/polls/static>
    Require all granted
</Directory>

I'm not sure where to go from here. I don't fully understand what the error means. I have Python installed in my Venv. There is a file pyenv.conf which reads

home = /usr
implementation = CPython
version_info = 3.6.9.final.0
virtualenv = 20.0.20
include-system-site-packages = false
base-prefix = /usr
base-exec-prefix = /usr
base-executable = /usr/bin/python3

I'm wondering if this base-executable path being different than my python path in the apache config file is causing problems, but I'm not sure exactly what I need to do from here (or if this is even part of the problem. I believe permissions should not be the issue since I added all of my files within the var/www/html folder.

Update: I added the recommended permissions to all files in the chain and that didn't change anything.

Any advice is appreciated.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda