Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' with Ubuntu Apache2

6,027 views
Skip to first unread message

이경문

unread,
Aug 26, 2016, 1:16:36 PM8/26/16
to modwsgi
I'm trying to set up my django(1.8) application with Ubuntu 14.04 , Apache2 and python 3.4.3.

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 below : 
[Fri Aug 26 16:49:24.387805 2016] [mpm_event:notice] [pid 2818:tid 139897210853248] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/4.5.5 Python/3.4.3 configured -- resuming normal operations
[Fri Aug 26 16:49:24.387868 2016] [core:notice] [pid 2818:tid 139897210853248] AH00094: Command line: '/usr/sbin/apache2'
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

My configuration file is below :
'/etc/apache2/apache2.conf'
: ~ Include /etc/apache2/httpd.conf

'/etc/apache2/httpd.conf'
:
WSGIScriptAlias / /home/ubuntu/Project/Project/Project/wsgi.py
WSGIDaemonProcess soongonara 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 everything is done , why does this error come to me? Please help me

Graham Dumpleton

unread,
Aug 26, 2016, 5:50:26 PM8/26/16
to mod...@googlegroups.com
Question also appeared on StackOverflow and was resolved there.


The WSGIPythonHome value was wrong. If it is set it is supposed to be the value of sys.prefix for a Python installation, if setting it is even necessary, which in this case it wouldn’t have.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages