9

I'm trying to set up my django(1.8) application with AWS EC2 having Ubuntu 14.04 , Apache2 , python 3.4.

When I run 'sudo service apache2 start' , the page keeps re-loading and the same error message is stacking at '/var/log/apache2/error.log'.

The error message is

[Fri Aug 26 2016] [mpm_event:notice] [pid n:tid m] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/4.5.5 Python/3.4.3 configured -- resuming normal operations [Fri Aug 26 2016] [core:notice] [pid n:tid m] AH00094: Command line: '/usr/sbin/apache2' Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'

My configuration is below :

I added one line: 'Include /etc/apache2/httpd.conf' at the bottom of '/etc/apache2/apache2.conf'.

'/etc/apache2/httpd.conf' :

WSGIScriptAlias / /home/ubuntu/project/project/project/wsgi.py
WSGIDaemonProcess project python-path=/home/ubuntu/project/project
WSGIProcessGroup project
WSGIPythonHome /usr/bin/python3.4

<Directory /home/ubuntu/project/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Alias /static/ /home/ubuntu/project/project/deploy_to_server/
<Directory /home/ubuntu/project/project/deploy_to_server>
Require all granted
</Directory>

I think I did it all done without something wrong.

But it keeps logging with the same error. Is there anything I'm missing?

I did change mod_wsgi/3.x Python/2.7 configured --> mod_wsgi/4.5.5 Python/3.4.3 configured for synchronizing the python version ALREADY

2 Answers 2

5

It was because of the line 'WSGIPythonHome /usr/bin/pytyon3.4' in /etc/apache2/httpd.conf.

Without this line, it runs without error thank you

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

2 Comments

As extra information. WSGIPythonHome if being set should refer to the directory give by sys.prefix for the Python installation. Note that WSGIPythonHome cannot be used to refer to a Python installation or virtual environment which is a different version than what mod_wsgi was compiled for. Thus if mod_wsgi compiled for Python 2.7, you cannot use it to try and force use of Python 3.5.
The key is that you need this line if and only if you are using a virtual environment. If you have installed python, and your pip dependencies like django are installed system-wide - simply omit the WSGIPythonHome directive.
4

For me it was trying to point to the python executable under the virtualenv.

Wrong:

WSGIPythonHome /path/to/virtualenv/bin/python3.4

Correct:

WSGIPythonHome /path/to/virtualenv/

This is as described in the WSGI documentation for virtual environments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.